Write functions that label each pixel in an intensity image according to its orientations.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am not sure if I can ask this kind of question here or not, but I would like you to check if my code meets the requirement for my assignment or not.
Assignment details
Tasks 1: Write functions that label each pixel in an intensity image according to
its orientations.
2. The second function should use wavelet decomposition. In this case, you do NOT
need to distinguish between 45 and 135 degrees edges. That is, just identify diagonal
edges.
Label = 1 for horizontal edges
Label = 2 for vertical edges
Label = 3 for diagonal edges
Label = 4 for non-edge pixels, i.e. magnitude of edge is below a given threshold
Tasks 2: Test your code with the two provided images (Image1 and Image2) and display
your results as indexed images with 4 levels if you use the second function. For each function, compare the results using 2
different (very different) thresholds to decide if the edges are strong enough.
Here is my code
function [EdgeImg, IndexImg] = Function2(InputImg, Threshold)
% image = imread('Image1.jpg');
image = InputImg;
if size(image, 3) == 3
image = rgb2gray(image);
end
[C,S] = wavefast(image,1,'haar');
figure;wavedisplay(C,S);
[NC,Y] = wavecut('a',C,S);
[NC,Y] = wavecut('v',NC,S,1);
[NC,Y] = wavecut('d',NC,S,1);
figure;wavedisplay(NC,S,-10);
[R1,NS] = waveback(NC,S,'haar',1);
figure;wavedisplay(R1,NS);
[NC,Y] = wavecut('a',C,S);
[NC,Y] = wavecut('h',NC,S,1);
[NC,Y] = wavecut('d',NC,S,1);
figure;wavedisplay(NC,S,-10);
[R2,NS] = waveback(NC,S,'haar',1);
figure;wavedisplay(R2,NS);
[NC,Y] = wavecut('a',C,S);
[NC,Y] = wavecut('h',NC,S,1);
[NC,Y] = wavecut('v',NC,S,1);
figure;wavedisplay(NC,S,-10);
[R3,NS] = waveback(NC,S,'haar',1);
figure;wavedisplay(R3,NS);
% Initial Edgelmg and Indexlmh??
EdgeImg = zeros(size(InputImg,1),size(InputImg, 2));
IndexImg = zeros(size(InputImg,1),size(InputImg, 2));
for k = 1:size(InputImg,1)
for m = 1:size(InputImg,2)
[R, jip] = max([R1(k,m), R2(k,m), R3(k,m)]);
if R >= Threshold
EdgeImg(k,m) = R;
IndexImg(k,m) = jip;
else
EdgeImg(k,m) = 0;
IndexImg(k,m) = 5;
end
end
end
end
Please let me know if there are mistakes or I need more code to meet the requirement.
Also, I would be happy if you could mention specific line or something like that.
Thank you for your kind help in advance.
1 Kommentar
Pratham Shah
am 27 Apr. 2023
Hello!
How can someone say if your code is meeting the assignment requirement? You ask yourself "Is the output coming as expected?". You can post the images mentioned in Task2 so that others can verify.
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!