sharpen / eliminate fuzziness in .jpg

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
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

sharpen / eliminate fuzziness in .jpg

Post by RCinSTP »

I am trying to get this image so there are just the simple basic color and lines, etc., and eliminate the "fuzzziness" between colors. For example, the pale blue represents lakes and that should be all one color, the line around the pale blue, should be a darker blue. I am trying to get a distinct colors, not all the pixels of blue between the pale and the darker.

https://goo.gl/photos/GDd26WTjVChqRTMw5
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sharpen / eliminate fuzziness in .jpg

Post by fmw42 »

Use an interactive color picker to select the main colors you want to have preserved. Make a colortable image as an appended image of each color as a pixel. Use -dither none -remap with the colortable image to process your image. See http://www.imagemagick.org/Usage/quantize/#remap

Code: Select all

convert -size 1x1 xc:"color1" xc:"color2" ... xc:"colorN" +append colortable.png
convert image -dither none -remap colortable.png result
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

Re: sharpen / eliminate fuzziness in .jpg

Post by RCinSTP »

Thank you! I can use an interactive color picker and get the various colors, but how do I make an appended image of each color? Do I use GIMP to create the appended image?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sharpen / eliminate fuzziness in .jpg

Post by fmw42 »

The first convert command above in my previous post is creating the appended colors to make the colortable. You just supply as many
xc:"color" arguments as needed as indicated by the ... xc:"colorN".
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

Re: sharpen / eliminate fuzziness in .jpg

Post by RCinSTP »

On the first line I get an error message "missing an image filename", so I changed the line as below:
convert c:\myimage.jpg xc:"bbd5fa" xc:"d3e0c6" +append c:\colortable.png
but, I no matter how colors I add, I always get an error message: "unrecognized color 'd3e0c6'
the last part of the error message has whatever color is the last color in the command line.
I also tried as below using colorN and substituting the N for the number of colors, but I also get an error message with tha.
convert c:\myimage.jpg xc:"bbd5fa" xc:"d3e0c6" cx:"color2" +append c:\colortable.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sharpen / eliminate fuzziness in .jpg

Post by fmw42 »

try this, with no input image.

Code: Select all

convert -size 1x1 xc:"color1" xc:"color2" ... xc:"colorN" +append colortable.png
Also hex colors must start with # as in #FF0000 for red

see http://www.imagemagick.org/script/color.php
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

Re: sharpen / eliminate fuzziness in .jpg

Post by RCinSTP »

Thank you for the clarification, that worked, I was able to create the colortable.png file. For the second line,when I write it as below, I get an error message: "unable to open image 'none': No such file or directory"

Code: Select all

convert c:\test.jpg -dither none -remap colortable.png c:\test\result.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sharpen / eliminate fuzziness in .jpg

Post by fmw42 »

That does not make sense. It should work. try

Code: Select all

convert c:\test.jpg +dither -remap colortable.png c:\test\result.jpg
Perhaps you need to put the full path to the colortable.png image. Seems you may have written it to some other directory from where you are running the script.

To make life simpler, I generally run the convert command from the directory where I have all my images, so that I do not have to use full paths. So change directories to where you have both test.jpg and colortable.png. The just run the command with only the file names. If you want the result in some other directory, then use the full path for that.
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

Re: sharpen / eliminate fuzziness in .jpg

Post by RCinSTP »

I put the images in the same directory as IM and then wrote the command line as below:

Code: Select all

convert test.jpg -dither none -remap colortable.png converted.jpg
but, I still get the error message, "unable to open image 'none'
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sharpen / eliminate fuzziness in .jpg

Post by fmw42 »

Did you try +dither rather than -dither none. If that does not work, post your command for creating the colortable.png image and I will try to process it.

What version of IM are you using? If old, then perhaps upgrade. Note that -remap used to be -map. So if you have a very old IM version, try -map rather than -remap.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: sharpen / eliminate fuzziness in .jpg

Post by snibgo »

RCinSTP wrote:unable to open image 'none'
What version of IM are you using? If older than 6.9.0, I suggest you upgrade.
snibgo's IM pages: im.snibgo.com
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

Re: sharpen / eliminate fuzziness in .jpg

Post by RCinSTP »

I downloaded the latest version of IM and installed it and put the test.jpg and colortable.png in the IM folder and the error message still shows the IM is expecting "none" to be a filename. Perhaps "none needs a minus or plus sign in front of it or something?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sharpen / eliminate fuzziness in .jpg

Post by fmw42 »

RCinSTP wrote:I downloaded the latest version of IM and installed it and put the test.jpg and colortable.png in the IM folder and the error message still shows the IM is expecting "none" to be a filename. Perhaps "none needs a minus or plus sign in front of it or something?
No, it should work.

Post your command to create the colortable image and I will test both commands.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: sharpen / eliminate fuzziness in .jpg

Post by glennrp »

If you succeed in getting what you asked for, you'll probably be disappointed in how "jaggy" the transitions between the light blue and dark blue become.
For example,

Code: Select all

convert test.jpg +dither -colors 15 test-c15+d.png
reduces the colors set to 15 colors, doesn't dither, and produces an image with jaggy lakeshores, contour lines, and numbers. Since you are starting with an image that has already been dithered and converted to JPEG, I don't know how to do much better. Are you wanting to have the final result in JPEG also? If so, try

Code: Select all

convert test.jpg +dither -colors 15 -quality 92 test+d-c15-q92.jpg
Try other small values for "-colors". For this image, "-colors 8" works fairly well.
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

Re: sharpen / eliminate fuzziness in .jpg

Post by RCinSTP »

I apologize, it has been sometime since I have worked with ImageMagick and I didn't realize that there is a version for Windows 64-bit, with full install. I finally figured this out, installed the correct version and now the commands are working fine.
I have many 256x256 pixel image tiles, similar to this image. I am trying to clean up these images so that I can convert them to vector images which I can then convert to a map for a GPS. The GPS map program only works with vector images. I'm using Vector Magic and the results are not quite good enough, that is why I am trying to clean up the images before converting them to vector. I've heard of potrace but my understanding is that it only works with black and white images.
http://vectormagic.com/
Post Reply