필터 지우기
필터 지우기

Eliminate the background of image

조회 수: 2 (최근 30일)
Maximum
Maximum 2015년 5월 17일
답변: Image Analyst 2015년 5월 17일
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
Maximum
Maximum 2015년 5월 17일
Yes. That's what I mean actually
Image Analyst
Image Analyst 2015년 5월 17일
Which one?!?!
Crop? Set to white? Set to some other gray level? Be super explicit. Maybe even attach a picture of your desired output.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2015년 5월 17일
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);

Community Treasure Hunt

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

Start Hunting!

Translated by