Hello, can anyone help me how to find the only whitepixels that mushrooms occupied in given image??

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Pratyush Roy
Pratyush Roy am 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!

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by