Image segmentation/blocking and get value from each block
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2014-4-17
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 个评论
更多回答(1 个)
PRABIRA KUMAR SETHY
2019-3-11
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!