Hello, can anyone help me how to find the only whitepixels that mushrooms occupied in given image??
1 view (last 30 days)
Show older comments
My Code:
clc;
clear all;
close all;
I=imread('50pic1.jpeg');
figure;
imshow(I)
g = rgb2gray(I);
figure;
imshow(g)
impixelinfo
BW=imbinarize(g);
figure;
imshow(BW)
noofWhitepixels=sum(BW(:))
disp(noofWhitepixels)
By using this code i am getting All no of whitepixels in an image but i only want whitepixels of mushrooms that occupied in an image
0 Comments
Accepted Answer
Pratyush Roy
on 30 Sep 2021
Hi Anuradha,
As per my understanding you want to find onl the white pixels in the image of the mushroom.
As a workaround, you can try using the imerode function to remove small white patches after binarizing the image with imbinarize. The following code snippet demonstrates the use of bith these functions:
im1 = imread('mushroom.jpeg');
gray_image = rgb2gray(im1);
bw_image = imbinarize(gray_image);
se = strel('line',11,90);
erodedBW = imerode(bw_image,se);
imshow(erodedBW)
Hope this helps!
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!