hello,someone correct me this program please.
I=imread('lena.jpg');
I=rgb2gray(I);
[i j]=size(I);
I=double(I)/255;
level=0.5;
%carte de gradient
MH= [1 2 1; 0 0 0;-1 -2 -1];
GH = conv2 (I, MH);
figure(1),imshow(GH), title('Contours horizontal');
MV= [-1 0 1; -2 0 2; -1 0 1];
GV = conv2 (I, MV);
figure(2),imshow(GV), title('Contours vertical');
G=sqrt(GH.*GH + GV.*GV);
G=im2bw(G,level);
figure(3),imshow(G), title('Contours global');
%direction du gradient
eq=imdivide(GH,GV);
eq=atan(eq);
eq= (eq*180)/pi;
figure(4),imshow(eq),title ('direction gradient');
%seuillage et suppression des non maximum locaux
for i = 1 : size(eq,1)
j = 1 : size(eq,2)
if level > eq(i,j)
eq(i,j) = 0;
if level < eq(i,j)
eq(i,j) = 255;
end
end
end
eq = im2bw(eq,level);
figure(5), imshow(eq)

댓글 수: 6

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 8월 2일
Issue?
malak alexos
malak alexos 2020년 8월 2일
1-deletion of local non-maxima is not correct because i didn't see any different between it and the result of (contours global).
2-the exercice is (Calculate and display a gradient with normalized values ​​between 0 and 255) so i want know if i should always convert the values of image in double and do the devision ( I=double/255)
3- i can do the threshold after calculate the direction of gradient or after magnitude
thanks for help
Image Analyst
Image Analyst 2020년 8월 2일
Try imgradient() and imgradientxy()
malak alexos
malak alexos 2020년 8월 3일
i dont want to work with function
Image Analyst
Image Analyst 2020년 8월 3일
Why not? Is it your homework assignment? If so, tag it as homework.
malak alexos
malak alexos 2020년 8월 3일
oook, thanks

댓글을 달려면 로그인하십시오.

답변 (0개)

질문:

2020년 8월 2일

댓글:

2020년 8월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by