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

1 次查看(过去 30 天)
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

采纳的回答

Pratyush Roy
Pratyush Roy 2021-9-30
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by