Eliminate the background of image

5 Ansichten (letzte 30 Tage)
Maximum
Maximum am 17 Mai 2015
Beantwortet: Image Analyst am 17 Mai 2015
Hi all.
I'm beginner in Matlab. I have this picture. I want image inside the circle one. How do I can eliminate the background?
  3 Kommentare
Maximum
Maximum am 17 Mai 2015
Yes. That's what I mean actually
Image Analyst
Image Analyst am 17 Mai 2015
Which one?!?!
Crop? Set to white? Set to some other gray level? Be super explicit. Maybe even attach a picture of your desired output.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 17 Mai 2015
Maximum, I still don't know what you want. How about cropping like I suggested? Does this work for you?
clc;
workspace; % Make sure the workspace panel with all the variables is showing.
format long g;
format compact;
fontSize = 18;
%===============================================================================
% Read in a demo image.
folder = pwd;
baseFileName = 'try1.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
% If it's really color, then convert to gray scale.
grayImage = grayImage(:,:,2);
end
% Display the original image.
subplot(1, 2, 1);
imshow(grayImage);
axis on;
title('Original Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
% Let's crop the image
croppedImage = imcrop(grayImage, [275, 218, 42, 42]);
subplot(1, 2, 2);
imshow(croppedImage);
axis on;
title('Cropped Image', 'FontSize', fontSize);

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by