Multiple peaks with peak_local_max
Hi, I'm trying to use peak_local_max for tree detection. The only problem is that I keep getting multiple peaks (image attached). I tried already a combination of different filters but no success. Can anyone help me out? Thank you
On 2015-04-08 04:03:27, Forest Applied Remote Sensing RG (FARS) <fars.rg@gmail.com> wrote:
I'm trying to use peak_local_max for tree detection. The only problem is that I keep getting multiple peaks (image attached). I tried already a combination of different filters but no success. Can anyone help me out?
The peak detector needs some attention. Here are other discussions about the topic: https://github.com/scikit-image/scikit-image/issues/1246 https://github.com/scikit-image/scikit-image/pull/1248 And ideas, feedback and especially PRs welcome. Stéfan
Stefan, Thanks for your help, but I end up solving the problem. I combined the gaussin filter plus the max filter. The result now is much better. Now I'm strugling to export the local maxima points. Is there a function to export the points from the local maxima? Cheers, JP
@FARS - My recommendation was going to be applying some blur first, I'm glad that worked for you. How have you labeled the red points in the image above? If they are in a separate - possibly boolean - array, you can extract the coordinate indices directly via `np.where` or `np.nonzero`. If not, we'll need a little more information about those red dots to advise. Josh On Thursday, April 9, 2015 at 10:12:29 AM UTC-5, Forest Applied Remote Sensing RG (FARS) wrote:
Stefan,
Thanks for your help, but I end up solving the problem. I combined the gaussin filter plus the max filter. The result now is much better.
Now I'm strugling to export the local maxima points. Is there a function to export the points from the local maxima?
Cheers,
JP
Thank you for you answer Josh, these red dots are actually an array, where each cell has a coordinate x and y. To be honest I wanted to export this red dots with the following structure: 590600,00 6890408,00 1019,04 This image I'm using each pixel has a geographic coordinate. But, at the moment I use the image in the scrip, the coordinates are lost and remains only basic pixel coordinates (i. e. 40, 412, 210). I'm quite new at scikit and python. So I'm trying to learn things with practice. Thanks for your attention Em quinta-feira, 9 de abril de 2015 17:22:51 UTC+2, Josh Warner escreveu:
@FARS - My recommendation was going to be applying some blur first, I'm glad that worked for you.
How have you labeled the red points in the image above? If they are in a separate - possibly boolean - array, you can extract the coordinate indices directly via `np.where` or `np.nonzero`. If not, we'll need a little more information about those red dots to advise.
Josh
On Thursday, April 9, 2015 at 10:12:29 AM UTC-5, Forest Applied Remote Sensing RG (FARS) wrote:
Stefan,
Thanks for your help, but I end up solving the problem. I combined the gaussin filter plus the max filter. The result now is much better.
Now I'm strugling to export the local maxima points. Is there a function to export the points from the local maxima?
Cheers,
JP
NumPy exclusively uses zero-indexed integers for indexing. What format does your raw data come from which has the coordinates? However, assuming this is a regularly sampled array you should be able to map the raw integer coordinate indices to true coordinates. This should be a fairly simple operation, but complicated somewhat if rotation is included. Less efficient in terms of memory, you could separate out known x/y coordinates as two separate NumPy arrays. Then directly index those with the raw coordinates to return your known good, calibrated values. Josh On Thursday, April 9, 2015 at 10:43:47 AM UTC-5, Forest Applied Remote Sensing RG (FARS) wrote:
Thank you for you answer Josh,
these red dots are actually an array, where each cell has a coordinate x and y. To be honest I wanted to export this red dots with the following structure:
590600,00 6890408,00 1019,04
This image I'm using each pixel has a geographic coordinate. But, at the moment I use the image in the scrip, the coordinates are lost and remains only basic pixel coordinates (i. e. 40, 412, 210). I'm quite new at scikit and python. So I'm trying to learn things with practice.
Thanks for your attention
Em quinta-feira, 9 de abril de 2015 17:22:51 UTC+2, Josh Warner escreveu:
@FARS - My recommendation was going to be applying some blur first, I'm glad that worked for you.
How have you labeled the red points in the image above? If they are in a separate - possibly boolean - array, you can extract the coordinate indices directly via `np.where` or `np.nonzero`. If not, we'll need a little more information about those red dots to advise.
Josh
On Thursday, April 9, 2015 at 10:12:29 AM UTC-5, Forest Applied Remote Sensing RG (FARS) wrote:
Stefan,
Thanks for your help, but I end up solving the problem. I combined the gaussin filter plus the max filter. The result now is much better.
Now I'm strugling to export the local maxima points. Is there a function to export the points from the local maxima?
Cheers,
JP
Josh, My data is originally a bmp image exported from ArcGIS. The image is georeferenced. So every pixel has a 3D coordinate, coordinate East and West (Planar), and the third coordinate height (x, y, z). Basically I want to import the image, run the peak_local_max algorithm, get the local maxima and export the points with the original 3D coordinates in a txt file. So far I was able to do everything except the export part. That is where I have problems. Em quinta-feira, 9 de abril de 2015 20:51:11 UTC+2, Josh Warner escreveu:
NumPy exclusively uses zero-indexed integers for indexing. What format does your raw data come from which has the coordinates?
However, assuming this is a regularly sampled array you should be able to map the raw integer coordinate indices to true coordinates. This should be a fairly simple operation, but complicated somewhat if rotation is included.
Less efficient in terms of memory, you could separate out known x/y coordinates as two separate NumPy arrays. Then directly index those with the raw coordinates to return your known good, calibrated values.
Josh
On Thursday, April 9, 2015 at 10:43:47 AM UTC-5, Forest Applied Remote Sensing RG (FARS) wrote:
Thank you for you answer Josh,
these red dots are actually an array, where each cell has a coordinate x and y. To be honest I wanted to export this red dots with the following structure:
590600,00 6890408,00 1019,04
This image I'm using each pixel has a geographic coordinate. But, at the moment I use the image in the scrip, the coordinates are lost and remains only basic pixel coordinates (i. e. 40, 412, 210). I'm quite new at scikit and python. So I'm trying to learn things with practice.
Thanks for your attention
Em quinta-feira, 9 de abril de 2015 17:22:51 UTC+2, Josh Warner escreveu:
@FARS - My recommendation was going to be applying some blur first, I'm glad that worked for you.
How have you labeled the red points in the image above? If they are in a separate - possibly boolean - array, you can extract the coordinate indices directly via `np.where` or `np.nonzero`. If not, we'll need a little more information about those red dots to advise.
Josh
On Thursday, April 9, 2015 at 10:12:29 AM UTC-5, Forest Applied Remote Sensing RG (FARS) wrote:
Stefan,
Thanks for your help, but I end up solving the problem. I combined the gaussin filter plus the max filter. The result now is much better.
Now I'm strugling to export the local maxima points. Is there a function to export the points from the local maxima?
Cheers,
JP
participants (3)
-
Forest Applied Remote Sensing RG (FARS)
-
Josh Warner
-
Stefan van der Walt