1 / 18

Peak finding for Canny

This code implements a peak finding algorithm known as Non-Maxima Suppression, commonly used in image processing. By analyzing a gradient magnitude matrix (`mag`) and applying slope checks, the algorithm identifies local maxima which are marked as candidates. Additionally, a Hysteresis Thresholding method processes these candidates to finalize which peaks are significant based on high (`HI`) and low (`LO`) thresholds. The result is an efficient way to detect key features in images, enhancing applications such as edge detection and feature extraction.

fancy
Download Presentation

Peak finding for Canny

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Peak finding for Canny Also called Non-maximaSuppression

  2. Actual code for Peaks • for(i=MR;i<256-MR;i++){ • for(j=MR;j<256-MR;j++){ • if((xconv[i][j]) == 0.0) { • xconv[i][j] = .00001; • } • slope = yconv[i][j]/xconv[i][j]; • if( (slope <= .4142)&&(slope > -.4142)){ • if((mag[i][j] > mag[i][j-1])&&(mag[i][j] > mag[i][j+1])){ • cand[i][j] = 255; • } • } • else if( (slope <= 2.4142)&&(slope > .4142)){ • if((mag[i][j] > mag[i-1][j-1])&&(mag[i][j] > mag[i+1][j+1])){ • cand[i][j] = 255; • } • } • else if( (slope <= -.4142)&&(slope > -2.4142)){ • if((mag[i][j] > mag[i+1][j-1])&&(mag[i][j] > mag[i-1][j+1])){ • cand[i][j] = 255; • } • }else{ • if((mag[i][j] > mag[i-1][j])&&(mag[i][j] > mag[i+1][j])){ • cand[i][j] = 255; • } • } • } • }

  3. Hysteresis (Double) Threshold • while(more){ • more = 0; • for(i=0;i<256;i++){ • for(j=0;j<256;j++){ • if(cand[i][j] == 255){ • if(mag[i][j] > HI){ • final[i][j] = 255; • more = 1; • cand[i][j] = 0; • } • else if(mag[i][j] < LO){ • final[i][j] = 0; • cand[i][j] = 0; • } • else if( (mag[i][j] > LO)&&(mag[i][j] < HI) ){ • for(p=-1;p<2;p++){ • for(q=-1;q<2;q++){ • if(final[i+p][j+q] == 255){ • final[i][j] = 255; • cand[i][j] = 0; • more = 1; • } • } • } • }/*end-last-else-if*/ • }/*end-first-if*/ • } • }/*end-first-for*/ • }/*end-while*/

More Related