i want to create bounding boxes for the intersection part of vertical and horizontal profile but i didn't get it how can i do it help me here is the code iam using
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clc;
clear;
close all;
R=imread('img_00155.bmp');
l=rgb2gray(R);
g1=imadjust(l);
V=imbinarize(l,0.7);
Im = mean(V(:));
Ima = max(V(:));
Pm = mean(Ima(:));
W1=0.25;
W2=0.5;
T1=W1.*Im;
T2=W2.*Ima;
T3=(1-W1-W2).*Pm;
T=T1+T2+T3;
T1=W1.*Im;
T2=W2.*Ima;
T3=(1-W1-W2).*Pm;
T=T1+T2+T3;
l(l < T*255) = 0;
[rows1, columns1]=size(l);
verticalProfile = sum(l, 1);
subplot(2,1,1);
plot(1:columns1, verticalProfile,'b-');
title('vertical');
s=size(verticalProfile);
horizontalProfile = sum(l, 2);
subplot(2,1,2);
plot(1:rows1, horizontalProfile,'b-');
title('horizontal');
mul1=ones(size(horizontalProfile)).*verticalProfile;
hhh=graythresh(mul1);
mul2 = horizontalProfile.*ones(size(verticalProfile));
kkk=graythresh(mul2);
fu1=imfuse(mul1,R,'blend','Scaling','none');
figure,imshow(fu1);
fu2=imfuse(mul2,R,'blend','Scaling','none');
figure,imshow(fu2);
fu3=imfuse(mul2,fu1,'blend','Scaling','none');
figure,imshow(fu3);
bboxes = regionprops(fu3,'BoundingBox');
hold on
figure,imshow(fu3);
for k = 1 : length(bboxes)
CurrBB = bboxes(k).BoundingBox;
if CurrBB(3)/CurrBB(4)>= 0.62 || CurrBB(3)/CurrBB(4)<= 0.30 ;
rectangle('Position', [CurrBB(1),CurrBB(2),CurrBB(3),CurrBB(4)],'EdgeColor', 'r', 'LineWidth', 2);
end
end
hold off

this is my original image
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Entering Commands finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!