Can anyone tell me what kernel the ImageProcessor.findEdges method uses?
The source comments refer to the Sobel filter, but I thought the Sobel filter was directional (one for edges in X and one for edges in Y). The results of the findEdges method appear to give a directionally independent gradient magnitude. so Can anyone tell me what kernel the ImageProcessor.findEdges method uses? and/or Can anyone find the actual source code? i.e. where is the 'filter' in: public void findEdges() { if (width>1) filter(FIND_EDGES); } thanx |
I don't know what kernel is actually used here - but I can tell you
that the normal Sobel filter computes a dX image and a dY image - AND THEN COMBINES these to get edgeStrength and edgeDirection. Some implementations (incorrectly, in my opinion) then discard the edgeDirection image and report back only a (directionally independent) gradient magnitude. So, the fact that you are seeing only the directionally independent gradient magnitude is not evidence that Sobel is not being used. On Oct 25, 2006, at 5:30 AM, Tony Shepherd wrote: > Can anyone tell me what kernel the ImageProcessor.findEdges method > uses? > The source comments refer to the Sobel filter, but I thought the Sobel > filter was directional (one for edges in X and one for edges in > Y). The > results of the findEdges method appear to give a directionally > independent > gradient magnitude. > > so Can anyone tell me what kernel the ImageProcessor.findEdges > method uses? > and/or Can anyone find the actual source code? i.e. where is the > 'filter' in: > > public void findEdges() { > if (width>1) > filter(FIND_EDGES); > } > > thanx -- Kenneth Sloan [hidden email] Computer and Information Sciences +1-205-934-2213 University of Alabama at Birmingham FAX +1-205-934-5473 Birmingham, AL 35294-1170 http://www.cis.uab.edu/sloan/ |
In reply to this post by Tony Shepherd
you're right.
I'm trying to replicate IJ's edgemap creator. I've written a method that convolves with Sobel filters in X and Y directions (gx and gy), then gets the gradient magnitude from sqrt(gx^2 + gy^2). However, the results are nothing like the edgemap from ip.findEdges(). My method is much more noise-sensitive. I tried convolving the filters with Gaussians first, i.e. {{1,1,1}, {1,1,1}, {1,1,1}} but still didn't get the same results. I found the 'nuts and bolts' in the ByteProcessor class but just can't interpret them. The kernel I'm looking for is hidden in the enigma code below..... p1 = p2; p2 = p3; p3 = pixels2[offset-rowOffset+1]&0xff; p4 = p5; p5 = p6; p6 = pixels2[offset+1]&0xff; p7 = p8; p8 = p9; p9 = pixels2[offset+rowOffset+1]&0xff; switch (type) { case BLUR_MORE: sum = (p1+p2+p3+p4+p5+p6+p7+p8+p9)/9; break; case FIND_EDGES: // 3x3 Sobel filter sum1 = p1 + 2*p2 + p3 - p7 - 2*p8 - p9; sum2 = p1 + 2*p4 + p7 - p3 - 2*p6 - p9; sum = (int)Math.sqrt(sum1*sum1 + sum2*sum2); if (sum> 255) sum = 255; |
In reply to this post by Tony Shepherd
> Can anyone tell me what kernel the ImageProcessor.findEdges method
> uses? > The source comments refer to the Sobel filter, but I thought the Sobel > filter was directional (one for edges in X and one for edges in Y). > The > results of the findEdges method appear to give a directionally > independent gradient magnitude. > > so Can anyone tell me what kernel the ImageProcessor.findEdges method > uses? > and/or Can anyone find the actual source code? i.e. where is the > 'filter' in: > > public void findEdges() { > if (width>1) > filter(FIND_EDGES); > } > Download the latest imageJ source from http://rsb.info.nih.gov/ij/download/src/ Extract the files and use the new Plugins>Utilities>Search command (added in v1.37) to search for "FIND_EDGES". In the search results, double click on the line "..source/ij/process/ByteProcessor.java", which will open ByteProcessor.java in ImageJ's built in text editor. Press ctrl-f (Edit>Search) and search again for "FIND_EDGES". This will take you to the Sobel filtering code in the filter() method of the ByteProcessor class. -wayne |
In reply to this post by Tony Shepherd
Hello,
Check: http://www.cee.hw.ac.uk/hipr/html/sobel.html I believe that the masks are encoded in the terms sum1 and sum2. Cheers, William On 10/25/06, Tony Shepherd <[hidden email]> wrote: > > you're right. > I'm trying to replicate IJ's edgemap creator. I've written a method that > convolves with Sobel filters in X and Y directions (gx and gy), then gets > the gradient magnitude from sqrt(gx^2 + gy^2). > However, the results are nothing like the edgemap from ip.findEdges(). My > method is much more noise-sensitive. I tried convolving the filters with > Gaussians first, i.e. > {{1,1,1}, > {1,1,1}, > {1,1,1}} > > but still didn't get the same results. I found the 'nuts and bolts' in the > ByteProcessor class but just can't interpret them. The kernel I'm looking > for is hidden in the enigma code below..... > > p1 = p2; p2 = p3; > p3 = pixels2[offset-rowOffset+1]&0xff; > p4 = p5; p5 = p6; > p6 = pixels2[offset+1]&0xff; > p7 = p8; p8 = p9; > p9 = pixels2[offset+rowOffset+1]&0xff; > switch (type) { > case BLUR_MORE: > sum = (p1+p2+p3+p4+p5+p6+p7+p8+p9)/9; > break; > case FIND_EDGES: // 3x3 Sobel filter > sum1 = p1 + 2*p2 + p3 - p7 - 2*p8 - p9; > sum2 = p1 + 2*p4 + p7 - p3 - 2*p6 - p9; > sum = (int)Math.sqrt(sum1*sum1 + sum2*sum2); > if (sum> 255) sum = 255; > |
In reply to this post by Tony Shepherd
you're right.
I'm trying to replicate IJ's edgemap creator. I've written a method that convolves with Sobel filters in X and Y directions (gx and gy), then gets the gradient magnitude from sqrt(gx^2 + gy^2). However, the results are nothing like the edgemap from ip.findEdges(). My method is much more noise-sensitive. I tried convolving the filters with Gaussians first, i.e. {{1,1,1}, {1,1,1}, {1,1,1}} but still didn't get the same results. I found the 'nuts and bolts' in the ByteProcessor class but just can't interpret them. The kernel I'm looking for is hidden in the enigma code below..... p1 = p2; p2 = p3; p3 = pixels2[offset-rowOffset+1]&0xff; p4 = p5; p5 = p6; p6 = pixels2[offset+1]&0xff; p7 = p8; p8 = p9; p9 = pixels2[offset+rowOffset+1]&0xff; switch (type) { case BLUR_MORE: sum = (p1+p2+p3+p4+p5+p6+p7+p8+p9)/9; break; case FIND_EDGES: // 3x3 Sobel filter sum1 = p1 + 2*p2 + p3 - p7 - 2*p8 - p9; sum2 = p1 + 2*p4 + p7 - p3 - 2*p6 - p9; sum = (int)Math.sqrt(sum1*sum1 + sum2*sum2); if (sum> 255) sum = 255; |
In reply to this post by Tony Shepherd
Thanks to all those who helped out.
Incase anyone else's has seen similar problems, It turns out that my edge detector was working fine, but when I displayed the results I got what looked like random noise, because I was casting large double values to bytes to view as a byte processor. ImageJ must be re-scaling edge magnitudes somewhere along the line to avoid this. T |
Free forum by Nabble | Edit this page |