How can I remove shadows in image segmentation?
Afficher commentaires plus anciens
I'm a beginner user of MATLAB. I'm working on a project about fruit segmentation. I took pictures of different fruits with a white background. I used HSV thresholding, then morphologic operations. My problem is that i'm not be able to remove shadows in inferior part so this makes the object bigger than real and my results are not so accurate.
Do you have ave any suggestions? Should I use different threshold?
I = imread('limone_prova.jpg');
if true
clc;
clear all;
close all;
workspace;
I = imread('limone_prova2.jpg'); figure(1); imshow (I,'InitialMagnification',17)
%crop I_crop=imcrop(I, [873.5 411.5 2910 2232]);
I_HSV=rgb2hsv(I_crop); H=I_HSV(:,:,1); %Hue S=I_HSV(:,:,2); %Saturation V=I_HSV(:,:,3); %Value
thr_S=(S > 0.20);
open_S = bwareaopen(thr_S, 6000);
se = strel('disk',15); closeMask = imclose(open_S, se);
mask = uint8(closeMask); mask = cast(mask, class(I_crop)); mask_R = mask .* I_crop(:,:,1); mask_G = mask .* I_crop(:,:,2); mask_B = mask .* I_crop(:,:,3); mask_RGB = cat(3, mask_R, mask_G, mask_B);
figure; imshow(mask_RGB) end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Segmentation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!