what is code for non-maxima suppression of a grey image

20 views (last 30 days)
Edge detection using wavelet transform need local maxima to find new approximation coefficient from detail coefficient.

Answers (3)

Sajid Khan
Sajid Khan on 10 Oct 2013
Hi, attached is the source code for non maximal suppression. I also have submitted the code in file exchange but it will take some time for approval. I got help from canny edge detection code given in image processing toolbox
  2 Comments
S. Sal
S. Sal on 24 Nov 2016
Edited: S. Sal on 24 Nov 2016
Hello Sajid Khan, I am getting this error while using nonMaximalSupp.m you shared, The error is as follows: ___________________________________________________________
Undefined function 'cannyFindLocalMaxima' for input arguments of type 'double'.
Error in nonMaximalSupp (line 19) idxLocalMax = cannyFindLocalMaxima(dir,dx,dy,magGrad); _________________________________________________
Can you refine it please ? Thanks
Swank Williams
Swank Williams on 1 Jul 2023
Edited: Swank Williams on 1 Jul 2023
Hi @S. Sal, for the function cannyFindLocalMaxima, you may have a try on the following codes. And you can find more details in the link https://www.cnblogs.com/mender/p/3501929.html
function idxLocalMax = cannyFindLocalMaxima(direction,ix,iy,mag)
[m,n] = size(mag);
switch direction
case 1
idx = find((iy<=0 & ix>-iy) | (iy>=0 & ix<-iy));
case 2
idx = find((ix>0 & -iy>=ix) | (ix<0 & -iy<=ix));
case 3
idx = find((ix<=0 & ix>iy) | (ix>=0 & ix<iy));
case 4
idx = find((iy<0 & ix<=iy) | (iy>0 & ix>=iy));
end
if ~isempty(idx)
v = mod(idx,m);
extIdx = (v==1 | v==0 | idx<=m | (idx>(n-1)*m));
idx(extIdx) = [];
end
ixv = ix(idx);
iyv = iy(idx);
gradmag = mag(idx);
switch direction
case 1
d = abs(iyv./ixv);
gradmag1 = mag(idx+m).*(1-d) + mag(idx+m-1).*d;
gradmag2 = mag(idx-m).*(1-d) + mag(idx-m+1).*d;
case 2
d = abs(ixv./iyv);
gradmag1 = mag(idx-1).*(1-d) + mag(idx+m-1).*d;
gradmag2 = mag(idx+1).*(1-d) + mag(idx-m+1).*d;
case 3
d = abs(ixv./iyv);
gradmag1 = mag(idx-1).*(1-d) + mag(idx-m-1).*d;
gradmag2 = mag(idx+1).*(1-d) + mag(idx+m+1).*d;
case 4
d = abs(iyv./ixv);
gradmag1 = mag(idx-m).*(1-d) + mag(idx-m-1).*d;
gradmag2 = mag(idx+m).*(1-d) + mag(idx+m+1).*d;
end
idxLocalMax = idx(gradmag>=gradmag1 & gradmag>=gradmag2);

Sign in to comment.


Image Analyst
Image Analyst on 24 Mar 2013
Sounds like you have a paper in mind. Did you ask the authors if they have code to share with you, or search the File Exchange? I don't have the wavelet toolbox so I can't help you.

Image Analyst
Image Analyst on 24 Nov 2016
Try the function imhmax() built in to the Image Processing Toolbox.

Categories

Find more on Communications Toolbox in Help Center and File Exchange

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!