How do i crop an image (delete the background)
조회 수: 6 (최근 30일)
이전 댓글 표시
I m new to Matlab but here is what I'm trying to do. Here is the original image https://picasaweb.google.com/117741942742967044268/MatlabTests#5715055956158535938
i'm trying to crop the box. is it possible that i crop this using a binary image like this? https://picasaweb.google.com/117741942742967044268/MatlabTests#5715056388429220994
if yes, but the mask is still not very clear. there are some black pixels inside the white area. how can i superfine it?
here is the code to generate the binary image from rgbImage:
% Convert image from RGB colorspace to lab color space.
cform = makecform('srgb2lab');
lab_Image = applycform(im2double(rgbImage),cform);
% Extract out the color bands from the original image
% into 3 separate 2D arrays, one for each color component.
LChannel = lab_Image(:, :, 1);
aChannel = lab_Image(:, :, 2);
bChannel = lab_Image(:, :, 3);
%Convert aChannel(double) to unit8 RGB image
aChannelToRgb8 = repmat (uint8(255.*aChannel),[1 1 3]);
%multiply the original rgb image with aChannelToRgb8
multiplyResult = immultiply (rgbImage,aChannelToRgb8);
%convert multiplyResult to binary with a level
BW = im2bw (multiplyResult, 0.4);
imshow (BW);
댓글 수: 0
채택된 답변
Image Analyst
2012년 3월 2일
Once you have the binary image you can use any() and find() to determine where the top line, bottom line, left column, and right column are. The call imcrop(). By the way you don't need to do all that stuff about going to LAB color space.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!