Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Find summation of white pixel of detected rectangle from a binary iamge??

조회 수: 1 (최근 30일)
Rajat
Rajat 2014년 5월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
im=imread('8.jpg'); %read above picture
im=im2bw(im,.555);
[row,col]=size(im);
area=(row*col)*.1;
stats = regionprops(im);
imshow(im);
hold on;
density=0;
for i = 1:numel(stats)
rect = [stats(i).BoundingBox];
count = 0;
if(rect(3)*rect(4)>area)
for j= fix(rect(1)):fix(rect(3))+fix(rect(1))% for every pixel of detected rectangle
for k= fix(rect(2)):fix(rect(4))+fix(rect(2))
if((j<=row && j>0 && k<=col && k>0)&&(im(j,k)== 1)) %count white pixel
count =count +1;
end
end
end
density=count/fix(rect(3))*fix(rect(4)); %count sum of white pixel/area
disp(count);
disp(density);
textRect =i;
rectangle('Position', stats(textRect).BoundingBox, ...
'Linewidth', 1, 'EdgeColor', 'r', 'LineStyle', '--');
f = getframe(gca);
im = frame2im(f);
imwrite(im,'8_rect.tif');
end
end
But i didnt get the appropriate value of the density of that detected area,it should be <1.
Can any one please help me to find out the pixel density of that detected rectangle??
Thank You in Advance.

답변 (1개)

Rajat
Rajat 2014년 5월 6일
There are lot of image like in SignBoard,Advertisement,Book which contain text and I want to classify the category of those image,so initially I classify based on detected rectangle and its pixel density.If you have any better idea please suggest me.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by