Image segmentation/blocking and get value from each block
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sazzad hossen
am 17 Apr. 2014
Beantwortet: PRABIRA KUMAR SETHY
am 11 Mär. 2019
First image is my input image i want to make 1)first divided(segment) my image into M*N block (like Second pic) 2) the i want to calculate(percentage of black and white color) from each block 3) then each block separate based on a threshold value of black or while percentage
i am new in image processing please give me a details explain, how can i solve my problem
Thanks in advance
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 17 Apr. 2014
Have you done step 1 yet? It look like it.
Then threshold the image with a fixed threshold that is just above the gray level of the chassis.
binaryImage = grayImage > threshold;
See the interactive thresholding utility/tool in my my File Exchange Also run the Image Segmentation Tutorial there.
Next you need to scan the blocks in your image. Assuming you have the rows and columns of the red lines, do something like this:
for xBlockIndex = 1 : length(columns)-1
col1 = columns(xBlockIndex);
col2 = columns(xBlockIndex+ 1) - 1;
for yBlockIndex = 1 : length(rows)-1
row1 = rows(yBlockIndex);
row2 = rows(yBlockIndex+1)-1;
% Extract sub image
subImage = grayImage(row1:row2, col1:col2);
% Extract mask sub image
subImageMask = binaryImage(row1:row2, col1:col2);
% Compute mean for pixel above the threshold.
meanGrayLevels(yBlockIndex, xBlockIndex) = mean(subImage(subImageMask));
end
end
10 Kommentare
Weitere Antworten (1)
PRABIRA KUMAR SETHY
am 11 Mär. 2019
Dear Rsearcher
I have a rice panicle iamge. Then I separate to number of block, which size is same as the size of grain. This much I completed.Code attached. Now I want to detect the defected grain (blackish) in each block by applying some kind of thresholding operation. Then show the blocks which contain the defected grain. Then count these blocks. kindly help me.
.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!