Removing noise from the image

조회 수: 3 (최근 30일)
Kumar Arindam Singh
Kumar Arindam Singh 2017년 4월 8일
편집: Image Analyst 2017년 4월 8일

I guess i have posted this earlier.

I have number of images in a folder. I have to crop those images(without using manual cropping). Now I have changed the images to binary images so that I can perform automatic cropping. Now, when I converted the images to their binary form, I am getting some noise which is preventing me from performing the cropping step. How can I remove the noise from each images? Please Help.

Example:-

I have this original image:-

I have converted the above image image to its binary form for cropping.

Now I found that there is a noise present at the bottom left corner of the binary image. How can I remove the noise such that the black colour of noise becomes white in colour.Please help.!

Also, since I have different images in my folder, the shape of the noise portion is also different in different images.How can I remove such noises from those images as well.??? Thanx in advance

채택된 답변

dhwani contractor
dhwani contractor 2017년 4월 8일
I am getting this result by following code...Hope this helps
I=rgb2hsv(RGBimg);
I1=I(:,:,2); % change to hsv and select the channel with most clear contrast between object and shadow
thresholded = I1 < 0.35;
SE = strel('disk',9);
IM2 = imerode(thresholded,SE);
imshow(IM2);
  댓글 수: 1
Kumar Arindam Singh
Kumar Arindam Singh 2017년 4월 8일
thanx a lot.... can u plzz help me ....i wanted to crop these images..... say for example i wanted to crop the original image and the output would be:-

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

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 4월 8일
Not sure why you accepted it if it's not working for you. You shouldn't use imerode(). You should use bwareafilt() instead. Then you can call regionprops() to get the bounding box, or use all() and indexing. Then use imcrop(). See my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
  댓글 수: 2
Kumar Arindam Singh
Kumar Arindam Singh 2017년 4월 8일
the code is working... that's y i thought of accepting the answer...okay i will see the tutorial
Image Analyst
Image Analyst 2017년 4월 8일
편집: Image Analyst 2017년 4월 8일
Well it's not doing the cropping like you wanted and the erosion will change the shape of the mask. Basically (untested)
hsvImage = rgb2hsv(rgbImage);
saturationImage = hsvImage(:,:,2);
leafMask = saturationImage > 0.35;
leafMask = bwareafilt(leafMask, 1);
leafMask = imfill(leafMask, 'holes');
labeledImage = bwlabel(leafMask);
props = regionprops(labeledImage, 'BoundingBox');
boundingBox = props.BoundingBox;
croppedImage = imcrop(rgbImage, boundingBox);

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

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by