필터 지우기
필터 지우기

[Help me,please] How to crop image, remove background of currency ?

조회 수: 2 (최근 30일)
Lee Bruce
Lee Bruce 2017년 6월 26일
댓글: Lee Bruce 2017년 6월 27일
Don't use imcrop(image,[]);
after (i crop with photoshop ^^).
Use boundary, edge...
Please help me, thank you for watching.
I am a beginer, i hope an answers.
My english is bad. @@
  댓글 수: 6
Jan
Jan 2017년 6월 26일
@Lee Bruce: Everything is fine. I did not make the laws and I think they are not really smart. It is just a good idea to ask, before the forum assists you to get into troubles.
Let's trust your teacher.

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

채택된 답변

Image Analyst
Image Analyst 2017년 6월 26일
This code will do it:
clc; % Clear the command window.
% close all; % Close all figures (except those of imtool.)
% clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
%===============================================================================
% Read in a standard MATLAB color demo image.
folder = pwd;
baseFileName = 'bmbkK.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
rgbImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorChannels should be = 3.
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Display the original color image.
subplot(2, 3, 1);
imshow(rgbImage);
title('Original Color Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
hsvImage = rgb2hsv(rgbImage);
sImage = hsvImage(:, :, 2);
subplot(2, 3, 2);
imshow(sImage, []);
title('Saturation Image', 'FontSize', fontSize, 'Interpreter', 'None');
subplot(2, 3, 3);
histogram(sImage);
grid on;
title('Histogram of Saturation Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Threshold.
mask = sImage > 0.1;
% Extract biggest blob.
mask = bwareafilt(mask, 1);
% Fill holes.
mask = imfill(mask, 'holes');
subplot(2, 3, 4);
imshow(mask);
title('Mask Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Get bounding box.
props = regionprops(logical(mask), 'BoundingBox');
% Crop image.
croppedImage = imcrop(rgbImage, props.BoundingBox);
subplot(2, 3, 5);
imshow(croppedImage);
title('Cropped Image', 'FontSize', fontSize, 'Interpreter', 'None');
  댓글 수: 1
Lee Bruce
Lee Bruce 2017년 6월 27일
Thank you so much.I will try more. Wish the best things will come to you.^^

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

추가 답변 (1개)

Jan
Jan 2017년 6월 26일
Do you have the Image Processing Toolbox and are you allowed to use it? You need a threshold at first to create a BW image. What about converting the RGB image to HSV colorspace, such that the grey/white pixels can be identified easily? Then a few pixels might be detected inside the banknote. which could be removed by a median filter. Finally regionprops with the 'BoundingBox' property might help. But you can search for the maximum and minimum rows and columns by find also.
Note that this forum does not post solutions of homework questions usually for good reasons. So try it and ask a specific question.
  댓글 수: 3
Jan
Jan 2017년 6월 26일
You have a GUI already. What are the inputs for the question you ask here? The filename or the image data? What have you tried so far? Giving suggestions for improvements is much easier than guessing, what you exactly need. So please explain explicitely, how we can help you.
Lee Bruce
Lee Bruce 2017년 6월 27일
Thank you for everything. I found the answer.^^

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

Community Treasure Hunt

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

Start Hunting!

Translated by