how to smooth image

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?".
Post Reply
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

how to smooth image

Post by VanGog »

Hi,
do you know some trick how to smooth this?

http://i50.tinypic.com/110ke9i.png

it is just resulting image, not the source. Source is 8bit RGB, half size of the result, but better quality. But when I enlarge the image 2x it is blured. I then sharpen the image in Photoshop and paste it into 256 index color document...

The resulting image is for bmp with 256 colors. It is image for game. Game graphics need simplified areas of color. If I take normal image and resize it, sometimes it has this ugly pixels. It is because on the walls black or orange is changed often. The results is that pixels of various color are there, and the result is not nice. I would need to simplify the areas of similar color. Is that possible? Yet you can see there are red pixel that should not be there.

I can use the original, so maybe image magick could work with it, and prepare the image - to smooth the areas which are similar color. My next step (which I do in Photoshop) will be to paste that image into empty image with 256 indexed colors. Maybe you have some function which could detects the nearest color from the image palette and then to smooth the areas which are similar to that color.

PS: When I write "simplify" and "smooth" I mean to convert the image, like it would be drawing or clipart. Something similar.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to smooth image

Post by fmw42 »

try this

convert 110ke9i.png -background black -alpha background \
\( -clone 0 -alpha off -median 7x7 \) \
\( -clone 0 -alpha extract \) \
-delete 0 -alpha off -compose copy_opacity -composite 110ke9i_new.png

What version of IM are you using? What platform? You should always supply that.

The above is for unix. If on windows remove the \ escape before the parens and replace the \ at the end of lines with ^

See
http://www.imagemagick.org/Usage/windows/
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

Sorry, but this is same result. Don't forget I will turn to index color in the palette of the image I sent you before. The Colorado are blured and mixed together. Try how it will look with 256 colors only.

Here is new image screenshot from photoshop
http://i46.tinypic.com/214a8pc.png
This is not that result I want, but it has something to demonstrate. The new demonstration image is not so exact, because many of the details are lost. It looks like drawing with a brush. You should note that the areas with same color are wider. I know, if you zoom in into details, you see the areas which seem same color are not same color too. Same problem. But you understand the goal. I need to connect that pixels into one color areas (not so big size).

That is what I would like to have. But not like Photoshop - I need the areas are less size, because otherwise the details are lost. This demonstration image of mine is unusable now because I would need to resize it to 124x81 px, with is very little size (not good for me).

PS: I am WIndows user
Version: ImageMagick 6.7.7-0 2012-05-17 Q16
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

PS: I have found some recommendation for program called Inkscape, that it can convert raster into vectors and create image look like clipart, so I will probably try. Maybe it could help.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

Well, in the Inkscape there is filter called Morphology/Erode (I used radius 1,8 - 2,8) and it does wonderful job! You can downloadit as OpenSource and try.

Filters->Filter Editor->New->Morphology->add->now set your params Erode, and your radius.

I could upload my image because I had to correct some problems on it, after corrections it would work.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to smooth image

Post by fmw42 »

IM has -morphology erode. It also works on color images

see
http://www.imagemagick.org/Usage/morphology/#erode
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

Is it possible to use octagon with decimal numbel? Loocs does not work:

convert chateau.png -morphology Erode Octagon:1.2 Octagon_1.2.png

Only Octagon:1 which is too little radius and Octagon:2, which is too big radius.

Any other smoothing techniques? This one is not good because it leaves "circles" like brush strokes on the picture. I would need more sophisticated method. For example to detect the colors with "circles" first, and then to detect the area which has same color and then to applicate the effect. -morphology Erode looks like it does not try to detect the area, it just draws the "circle".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to smooth image

Post by fmw42 »

Octagon only uses integers for the radius of the shape. Try other shapes such as square or diamond. Those should give intermediate results. However, I suspect you want something else that IM cannot do.

You can also try changing my median 7x7 earlier with -statistic mode 7x7. See if that is more what you want.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

fmw42 wrote:You can also try changing my median 7x7 earlier with -statistic mode 7x7.
What do you speak about?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to smooth image

Post by fmw42 »

VanGog wrote:
fmw42 wrote:You can also try changing my median 7x7 earlier with -statistic mode 7x7.
What do you speak about?
convert 110ke9i.png -background black -alpha background \
\( -clone 0 -alpha off -statistic mode 7x7 \) \
\( -clone 0 -alpha extract \) \
-delete 0 -alpha off -compose copy_opacity -composite 110ke9i_new.png
Last edited by fmw42 on 2012-08-20T14:50:59-07:00, edited 1 time in total.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

I don't know, what I do have wrong in my Windows syntax?

Code: Select all

convert chateau.png -background black -alpha background ^
   ( -clone 0 -alpha off -statistic mode ) ^
   ( -clone 0 -alpha extract ) ^
   -delete 0 -alpha off -compose copy_opacity -composite static_chateau.png
Not valied argument - -background
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to smooth image

Post by fmw42 »

VanGog wrote:I don't know, what I do have wrong in my Windows syntax?

Code: Select all

convert chateau.png -background black -alpha background ^
   ( -clone 0 -alpha off -statistic mode ) ^
   ( -clone 0 -alpha extract ) ^
   -delete 0 -alpha off -compose copy_opacity -composite static_chateau.png
Not valied argument - -background
Sorry when cutting a pasting I accidentally remove the 7x7 size or whatever size you want.

Try

convert chateau.png -background black -alpha background ^
( -clone 0 -alpha off -statistic mode 7x7 ) ^
( -clone 0 -alpha extract ) ^
-delete 0 -alpha off -compose copy_opacity -composite static_chateau.png
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

I'm not sure from which system I had run the command. I will test it later on different system.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

Thanks a lot for those command. It's amazing. Much more better then those previous. I applied it on original sized image and then I did resize

New version of the castle (original size):
http://i45.tinypic.com/20kp114.png
Resized version with different palette:
http://i45.tinypic.com/4kuwit.jpg
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: how to smooth image

Post by pipitas »

VanGog wrote:Thanks a lot for those command. It's amazing. Much more better then those previous. I applied it on original sized image and then I did resize

New version of the castle (original size):
http://i45.tinypic.com/20kp114.png
Resized version with different palette:
http://i45.tinypic.com/4kuwit.jpg
If you put 'img' tags around your image URLs like this:

Code: Select all

[img]http://...[/img]
we could see them directly in this forum and wouldn't need to open new tabs to go and look there... :D See for yourself:
VanGog wrote:New version of the castle (original size):
Image
Resized version with different palette:
Image
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: how to smooth image

Post by VanGog »

I dont like img tag for those big images, because I dont see it whole. This is better to view.
Post Reply