Questions mean shift noise removal and color reduction

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Questions mean shift noise removal and color reduction

Post by fmw42 » 2017-08-03T09:42:01-07:00

aigo wrote:
2017-08-03T03:22:39-07:00
Hi again,

I understand what the windows size does now, sorry about that.

But, is it possible to specify the number of colors it can replace originals with (the number of colors in this case can be viewed as the number of clusters).

Say, for example I select 5 colors then when computing the mean of each window size, it selects the colour nearest to the mean (color) from my pre-specified color range (5 colors)?

If there is a function, that does this already. Kindly point me there.

Best,

Aigo!
No, you cannot specify numbers of color for mean-shift. But see my bash unix shell script, kmeans, at my link below. It can do that.

aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: New: mean shift noise removal and color reduction

Post by aigo » 2017-08-03T11:27:14-07:00

Hi Fred, I tried using the script but I keep on getting a white image.. I only used -n in the process.

Kindly help.

Thanks.

Aigo!

User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: New: mean shift noise removal and color reduction

Post by fmw42 » 2017-08-03T11:42:55-07:00

aigo wrote:
2017-08-03T11:27:14-07:00
Hi Fred, I tried using the script but I keep on getting a white image.. I only used -n in the process.

Kindly help.

Thanks.

Aigo!
What is your IM version and platform? What was the command line you used? Did you follow the Pointers for use on my home page?

aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: New: mean shift noise removal and color reduction

Post by aigo » 2017-08-04T03:37:16-07:00

fmw42 wrote:
2017-08-03T11:42:55-07:00
aigo wrote:
2017-08-03T11:27:14-07:00
Hi Fred, I tried using the script but I keep on getting a white image.. I only used -n in the process.

Kindly help.

Thanks.

Aigo!
What is your IM version and platform? What was the command line you used? Did you follow the Pointers for use on my home page?
7.0.6-0 macOS Sierra
this is the command I used !sh kmeans.sh -n 20 faces.png faces_k10.png

User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Questions mean shift noise removal and color reduction

Post by fmw42 » 2017-08-04T09:11:54-07:00

It should be

bash kmeans.sh -n 20 faces.png faces_k10.png

Perhaps you can post your faces.png image to some free hosting service and put the URL here so I can test your image.

User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Questions mean shift noise removal and color reduction

Post by fmw42 » 2017-08-04T09:22:30-07:00

OK. I found your image on your other question. This is what I get.

Code: Select all

kmeans -n 10 -m 10 faces.png faces_kmeans_n10_m10.png
final colors:
count,hexcolor
94425,#ECF6FDFF
37772,#CDDEF3FF
34831,#D69D7BFF
23775,#B8C9DEFF
22432,#AE7658FF
19588,#744E3EFF
17833,#EAC1A7FF
16491,#312020FF
13564,#B3B6BDFF
7589,#8B98A1FF
Image

User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Questions mean shift noise removal and color reduction

Post by fmw42 » 2017-08-04T10:37:34-07:00

Here is the mean-shift result

Code: Select all

convert faces.png -mean-shift 51x51+10% faces_mean_shift.png
Image

And then the mean shift result processed by kmeans.

Code: Select all

kmeans -n 10 -m 10 faces_mean_shift.png faces_mean_shift_kmeans_n10_m10.png
final colors:
count,hexcolor
91585,#EBF7FEFF
42985,#D89F7DFF
37150,#CDDFF5FF
26843,#B5CAE2FF
20687,#AB7356FF
19686,#704C3CFF
15108,#C4BBBBFF
14849,#2D1E1FFF
12282,#F2CCB0FF
7125,#899EAAFF
Image

aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Questions mean shift noise removal and color reduction

Post by aigo » 2017-08-05T01:17:47-07:00

fmw42 wrote:
2017-08-04T09:11:54-07:00
It should be

bash kmeans.sh -n 20 faces.png faces_k10.png

Perhaps you can post your faces.png image to some free hosting service and put the URL here so I can test your image.
Thanks so much for this and the other examples.

But I still get the white image.

Could this be a platform problem?

Thanks!

Aigo.

aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Questions mean shift noise removal and color reduction

Post by aigo » 2017-08-05T01:19:37-07:00

aigo wrote:
2017-08-05T01:17:47-07:00
fmw42 wrote:
2017-08-04T09:11:54-07:00
It should be

bash kmeans.sh -n 20 faces.png faces_k10.png

Perhaps you can post your faces.png image to some free hosting service and put the URL here so I can test your image.
Thanks so much for this and the other examples.

But I still get the white image.

Could this be a platform problem?

Thanks!

Aigo.
Image

User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Questions mean shift noise removal and color reduction

Post by fmw42 » 2017-08-05T10:40:37-07:00

The error message you get is because you did not put the path to my script(s) in your PATH environment variable. However, that does not cause the script to fail. But I find there is a problem running the script with IM 7. I am trying to track that down now.

User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Questions mean shift noise removal and color reduction

Post by fmw42 » 2017-08-05T11:29:44-07:00

I have fixed one issue. But there is a bug in IM 7 with one function when the temp images are miff, that is causing the main problem of the white image. I will have to report it to the IM developers. In the mean time, if you want to run the script, download the newest version and globally replace .miff with .png, which seems to work for me on IM 7.0.6.5 Q16 Mac OSX Sierra

aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Questions mean shift noise removal and color reduction

Post by aigo » 2017-08-05T11:55:45-07:00

Yeah..I have done that and it works perfectly.

Thanks!

User avatar
fmw42
Posts: 22079
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Questions mean shift noise removal and color reduction

Post by fmw42 » 2017-08-05T12:08:55-07:00

I have found a workaround for the IM 7 issue. So you can download the latest version and will not have to replace .miff with .png

aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Questions mean shift noise removal and color reduction

Post by aigo » 2017-08-05T12:16:48-07:00

Aah Nice..Thanks..

snibgo
Posts: 9378
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Questions mean shift noise removal and color reduction

Post by snibgo » 2017-08-06T15:47:55-07:00

I get these results with an unpublished process module, based on http://people.csail.mit.edu/tieu/notebo ... amerly.pdf

k-means, without SD normalisation:

Image

k-means, with SD normalisation*:

Image

fuzzy k-means, without SDN:

Image

k-harmonic, without SDN:

Image

* SD normalisation is: before the process, multiply channels by ratio of standard deviations, to make SDs roughly equal in each channel. After the process, divide by the same numbers.
snibgo's IM pages: im.snibgo.com

Post Reply