Re: Clustering of an image by taking into account the spatial context of each pixel (besides its intensity)
Hi Jonas, Thanks for your response. That's exactly what I've tried this week-end, by adding the (x, y) to gray-level intensity and giving the matrix of 3-components vector as input to k-means. As for the normalization, I applied this formula to each column (intensity, x, y): (value - mean) / std_dev. But, even with this normalization step, adding the (x, y) coordinates will influence the pixels on the left (resp. right) to be grouped together (See http://imgur.com/HxfkRig and original image taken from http://uk.mathworks.com/help/images/texture-segmentation-using-gabor-filters...). Maybe I will need to find another normalization to apply of the (intensity, x, y) space. Le lundi 23 novembre 2015 23:53:34 UTC, Jonas Wulff a écrit :
Hi Hakim,
Have you tried just adding the coordinates of a pixel to its features? For each pixel, the features would then be R,G,B,X,Y. From your description, that seems what you're looking for.
So if you have an RGB image I (so that I.shape = (height,width,3)), you can do:
y,x = np.mgrid[:height,:width] I_stacked = np.dstack((I,x,y)) data = I_stacked.reshape((-1,5))
... and then use "data" as input to your clustering algorithm.
You might want to scale / normalize the coordinates to fit the general range of your color values -- but in general, this should do what I think you're looking for.
Cheers, -Jonas
On Sat, Nov 21, 2015 at 2:23 AM, Hakim Benoudjit <h.ben...@gmail.com <javascript:>> wrote:
Hi Juan,
Thanks for your answer, this seems to be a nice algorithm for the denoising of speckle. But actually I'm looking for an image clustering (segmentation) technique instead (that would take into consideration the spatial context of pixels).
Le samedi 21 novembre 2015 00:47:21 UTC, Juan Nunez-Iglesias a écrit :
Hey Hakim,
The right answer here depends on your ultimate goal. If you're after denoising, non-local means denoising (recently added to skimage) sounds like exactly what you're after.
Juan.
On Sat, Nov 21, 2015 at 11:28 AM, Hakim Benoudjit <h.ben...@gmail.com> wrote:
Hi Stéfan,
Thanks for your reponse. What I'm looking for is a *spatial criteria* that encourages the *clustering algorithm* (K-means or others) to group together similar *neighbouring pixels* inside the same cluster. This will help avoid having persistent noise inside a cluster.
Le vendredi 20 novembre 2015 13:20:15 UTC, Hakim Benoudjit a écrit :
Hi,
Is there a clustering algorithm implemented in *scikit-image *that perform the image clustering by taking into account the *spatial context *of the clustered pixel (its neighbourhood), besides its *pixel brightness*?
For the time being, I'm clustering images by reshaping them as vectors of pixels intensities distributions, and then performing the *K-means *or *Gaussian mixture models* implemented in *scikit-learn*. But, I'm looking for a image clustering technique implemented (or could be implemented) in *scikit-image *that would consider the neighbourhood of a pixel when classifying it.
Thanks.
-- You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com. To post to this group, send email to scikit...@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/0aad2045-b9da-442c-97bc-06c59... <https://groups.google.com/d/msgid/scikit-image/0aad2045-b9da-442c-97bc-06c596b0469e%40googlegroups.com?utm_medium=email&utm_source=footer> .
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com <javascript:>. To post to this group, send email to scikit...@googlegroups.com <javascript:>. To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/a2895510-2490-4ccf-a70a-20d67... <https://groups.google.com/d/msgid/scikit-image/a2895510-2490-4ccf-a70a-20d67c74d2cd%40googlegroups.com?utm_medium=email&utm_source=footer> .
For more options, visit https://groups.google.com/d/optout.
Incidentally, it seems you are just doing SLIC on a non-RGB image... Which SLIC supports. (skimage.segmentation.slic). The "compactness" parameter changes the weighting of intensity and space. On Tue, Nov 24, 2015 at 11:19 AM, Hakim Benoudjit <h.benoudjit@gmail.com> wrote:
Hi Jonas,
Thanks for your response. That's exactly what I've tried this week-end, by adding the (x, y) to gray-level intensity and giving the matrix of 3-components vector as input to k-means. As for the normalization, I applied this formula to each column (intensity, x, y): (value - mean) / std_dev. But, even with this normalization step, adding the (x, y) coordinates will influence the pixels on the left (resp. right) to be grouped together (See http://imgur.com/HxfkRig and original image taken from http://uk.mathworks.com/help/images/texture-segmentation-using-gabor-filters... ).
Maybe I will need to find another normalization to apply of the (intensity, x, y) space.
Le lundi 23 novembre 2015 23:53:34 UTC, Jonas Wulff a écrit :
Hi Hakim,
Have you tried just adding the coordinates of a pixel to its features? For each pixel, the features would then be R,G,B,X,Y. From your description, that seems what you're looking for.
So if you have an RGB image I (so that I.shape = (height,width,3)), you can do:
y,x = np.mgrid[:height,:width] I_stacked = np.dstack((I,x,y)) data = I_stacked.reshape((-1,5))
... and then use "data" as input to your clustering algorithm.
You might want to scale / normalize the coordinates to fit the general range of your color values -- but in general, this should do what I think you're looking for.
Cheers, -Jonas
On Sat, Nov 21, 2015 at 2:23 AM, Hakim Benoudjit <h.ben...@gmail.com> wrote:
Hi Juan,
Thanks for your answer, this seems to be a nice algorithm for the denoising of speckle. But actually I'm looking for an image clustering (segmentation) technique instead (that would take into consideration the spatial context of pixels).
Le samedi 21 novembre 2015 00:47:21 UTC, Juan Nunez-Iglesias a écrit :
Hey Hakim,
The right answer here depends on your ultimate goal. If you're after denoising, non-local means denoising (recently added to skimage) sounds like exactly what you're after.
Juan.
On Sat, Nov 21, 2015 at 11:28 AM, Hakim Benoudjit <h.ben...@gmail.com> wrote:
Hi Stéfan,
Thanks for your reponse. What I'm looking for is a *spatial criteria* that encourages the *clustering algorithm* (K-means or others) to group together similar *neighbouring pixels* inside the same cluster. This will help avoid having persistent noise inside a cluster.
Le vendredi 20 novembre 2015 13:20:15 UTC, Hakim Benoudjit a écrit :
Hi,
Is there a clustering algorithm implemented in *scikit-image *that perform the image clustering by taking into account the *spatial context *of the clustered pixel (its neighbourhood), besides its *pixel brightness*?
For the time being, I'm clustering images by reshaping them as vectors of pixels intensities distributions, and then performing the *K-means *or *Gaussian mixture models* implemented in *scikit-learn*. But, I'm looking for a image clustering technique implemented (or could be implemented) in *scikit-image *that would consider the neighbourhood of a pixel when classifying it.
Thanks.
-- You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com. To post to this group, send email to scikit...@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/0aad2045-b9da-442c-97bc-06c59... <https://groups.google.com/d/msgid/scikit-image/0aad2045-b9da-442c-97bc-06c596b0469e%40googlegroups.com?utm_medium=email&utm_source=footer> .
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com. To post to this group, send email to scikit...@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/a2895510-2490-4ccf-a70a-20d67... <https://groups.google.com/d/msgid/scikit-image/a2895510-2490-4ccf-a70a-20d67c74d2cd%40googlegroups.com?utm_medium=email&utm_source=footer> .
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com. To post to this group, send email to scikit-image@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/5e41ffef-c3a3-421f-b6e4-d5566... <https://groups.google.com/d/msgid/scikit-image/5e41ffef-c3a3-421f-b6e4-d5566b5c37c0%40googlegroups.com?utm_medium=email&utm_source=footer> .
For more options, visit https://groups.google.com/d/optout.
participants (2)
-
Hakim Benoudjit
-
Juan Nunez-Iglesias