Is my bar graph accurately graphing what I ask?

1 visualizzazione (ultimi 30 giorni)
i have an image which i have divided into 12 regions. I have made a code that I think counts the number of green dots in that image and plots them in a bar graph as function of the region in the image. is the code doing what i expect it to do? please correct or confirm.
First, the code converts the image (premask) into a gray image then applies a mask (screenshot). now that the mask is applied i want to count those specks as a function of their region because i want to see how the specks fluctate by number across the image in its differnt regions.
% count the graylevel specks and plot as a function of the region number (the once green specks).
greenspots = (g<255);
numberofgreenspots = numel(grayImage);
[pixelCounts, grayLevels] = imhist(grayImage);
%meanGL(k) = mean(grayImage(masksinusoid));
bar(numberofgreenspots, 1:length(endingColumns));
grid on;
xlabel('green speck #')
ylabel('region #')

Risposta accettata

Image Analyst
Image Analyst il 3 Feb 2023
No, you'd need to do this
% count the graylevel specks and plot as a function of the region number (the once green specks).
for k = 1 : whatever
greenSpotMask = g < 255; % g is the image of just this strip only.
% Count pixels.
areaOfGreenSpots(k) = nnz(greenSpotMask)
% Count number of contiguous regions.
[~, numberOfGreenSpots(k)] = bwlabel(greenSpotMask);
% Display histogram of strip.
[pixelCounts, grayLevels] = imhist(g);
%meanGL(k) = mean(grayImage(masksinusoid));
grid on;
title('Counting of Green Spots per Strip Region')
xlabel('Region #')
ylabel('Number of green spots in the region')
  9 Commenti
Neo il 3 Feb 2023
So i can understand your though process better, why did you plot them seperatley?
Image Analyst
Image Analyst il 3 Feb 2023
They represent totally different things and have different ranges. The number of pixels might be in the hundreds of thousands and the number might be a few dozen or hundred. You'd need at least 2 y axes, using yyaxis(), to plot them on the same plot. Like I said, the number of spots, like what you names the variable at the beginning, is most likely not what you want. You probably want the number of pixels (which is the area).

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by