Magick equivalent of GIMP Hue-Chroma transformation - imagemagick

Using Gimp, given an input image, I can improve its contrast using Colors > Hue Chroma... by setting Chroma=50 (in a scale between -100 and 100) and leaving Hue=0 and Lightness=0. So it appears I'm doing an HCL transformation.
Is there an equivalent command for Magick?
The following image shows the GIMP effect:
Image

Updated Answer
Not sure about this at all. I think you can get pretty close with -modulate if you go into an LCH colourspace, but I have no idea if it will work consistently. I got:
magick cXDv3.jpg -define modulate:colorspace=LCH -modulate 100,150 result.jpg
If that doesn't work, or is not to your liking, read on...
Generic Method for any GIMP filters
The method below should allow you to replicate any GIMP filter with ImageMagick - as long as it is a pure "point process", I mean one where each pixel's output value is purely derived from its input value and not an "area process" where surrounding pixels contribute - such as blurring or median filtering, for example.
It's called a HALD-CLUT. You would create a HALD-CLUT something like this:
magick hald:16 clut.png
Then take that file (clut.png) into GIMP and apply your GIMP processing on it and save the result as GIMP-H0-C50-L0.png so we know how GIMP affects each colour. You do that just once.
Then you go back to ImageMagick and apply that CLUT to your image:
magick input.png GIMP-H0-C50-L0.png -hald-clut result.png
That gives me this:
and I think you'll agree the left side looks pretty similar to the right side of your input image.
Original Answer
I don't know what that command does in GIMP, but you can convert to HCL colourspace in ImageMagick and select the Chroma channel for modification like this:
magick INPUT.PNG -colorspace HCL -channel G ...
You then want to do something ? to affect the Chroma channel, so try -auto-level for now, and then return to sRGB colourspace and save:
magick INPUT.PNG -colorspace HCL -channel G -auto-level +channel -colorspace sRGB RESULT.PNG
Then you need to provide more clues or experiment more with what that command does in GIMP - or provide examples.

Related

Resize an image with 54x54 squares (540x540) to 54x54pixel lossless

I've got an 540x540 image of 54x54 color squares (same sizes).
When I resize it to 54x54px it looks horrible (blurred), shouldn't a resize like this be perfectly done with imagemagick?
is I possible to get it perfect?
I've tested convert source.png -resize destination.png and -adaptive-resize but the result is the same..
I see what your confusion is now... the problem is not that the process is lossy, rather it is because the -resize is doing more sophisticated processing than you want in order to make an attractive job that you would want for, say, photographs. You want a very simple point sampling process which will produce simple blocks of pure, uncombined colour.
I'll make a start image:
magick -size 10x10 xc:red +noise random -scale 540x540 start.png
And scale it down, by taking a point sample in each block:
magick start.png -sample 10x10 small.png
And back up:
magick result.png -scale 540x540 reincarnated.png

generate image of certain resolution containing black and white noise

How how would i generate an image of certain resolution containing black and white noise. I want to generate a number of images with each images noise being different. Prefer if done in console of either linux or windows but coding is ok if really have to.
Cheers
Like this with ImageMagick which is installed on most Linux distros and is available for macOS and Windows:
convert -size 512x512 xc:gray +noise random -colorspace gray noise.jpg
Replace convert with magick if using v7+ of ImageMagick.
If you mean pure black and white without shades of grey, and maybe would like a different size and a PNG format, use:
convert -size 600x400 xc:gray +noise random -colorspace gray -threshold 50% noise.png
If you want a different distribution of noise (gaussian, poisson, binomial) or to attenuate the noise, have a look at my other answer here.

How do I convert EXR to PNG and adjust brightness at the same time

I was able to convert my EXR image to a PNG using the techniques outlined in Image conversion from IFF and EXR formats to JPEG format .
convert 0007.exr /tmp/0007.png
Unfortunately the PNG looks quite dim.
What should I add to the imagemagick convert command line to increase the brightness?
Starting with this:
You could try -auto-gamma:
convert start.jpg -auto-gamma result.jpg
If the -auto-gamma overcooks the image for your liking, you could apply a percentage of it. So, here I clone the original image and apply auto-gamma to the clone but then only blend 80% back into the original because I feel auto-gamma overdoes it:
convert start.jpg \( +clone -auto-gamma \) \
-define compose:args=80 -compose blend -composite result.jpg
Or, another option, you could experiment with your particular images and maybe try using -modulate for the brightness, where 100% means "do nothing", so numbers over 100 increase the brightness:
convert start.jpg -define modulate:colorspace=LCHuv -modulate 160 result.jpg
You can try -auto-level, which will take the minimal value and the maximal value of your picture and then stretches the values to the full range of values:
convert input.exr -auto-level output.jpg
Note that if you picture was too bright and this does not help, then it might be that your image is stored with 32 Bit, while ImageMagick is working with 16 Bit and no HDRI support. 32 Bit input is supported if convert --version
either show Q32 as part of the version string or lists HDRI under features.
Depending on your operating system you might be able to install another variant of ImageMagick. For example, for Debian Buster we can use sudo apt list imagemagick* to see that the package imagemagick-6.q16hdri is available. Installing this package provides convert-im6.q16hdri, which allows reading 32 Bit EXR images.
EXR is in linear RGB colorspace. You want to convert it to non-linear sRGB colorspace in Imagemagick as:
Input:
convert image.exr -set colorspace RGB -colorspace sRGB output.png

How to treshold image from greyscale screen by webcome

I have image like this from my windstation
I have tried get thoose lines recognized, but lost becuase all filters not recognize lines.
Any ideas what i have use to get it black&white with at least some needed lines?
Typical detection result is something like this:
I need detect edges of digit, which seams not recognized with almost any settings.
This doesn't provide you with a complete guide as to how to solve your image processing question with opencv but it contains some hints and observations that may help you get there. My weapon of choice is ImageMagick, which is installed on most Linux distros and is available for OS X and Windows.
Firstly, I note you have date and time across the top and you haven't cropped correctly at the lower right hand side - these extraneous pixels will affect contrast stretches, so I crop them off.
Secondly, I separate your image in 3 channels - R, G and B and look at them all. The R and B channels are very noisy, so I would probably go with the Green channel. Alternatively, the Lightness channel is pretty reasonable if you go to HSL mode and discard the Hue and Saturation.
convert display.jpg -separate channel.jpg
Red
Green
Blue
Now make a histogram to look at the tonal distribution:
convert display.jpg -crop 500x300+0+80 -colorspace hsl -separate -delete 0,1 -format %c histogram:png:ahistogram.png
Now I can see all your data are down the dark, left-hand end of the histogram, so I do a contrast stretch and a median filter to remove the noise
convert display.jpg -crop 500x300+0+80 -colorspace hsl -separate -delete 0,1 -median 9x9 -normalize -level 0%,40% z.jpg
And a final threshold to get black and white...
convert display.jpg -crop 500x300+0+80 -colorspace hsl -separate -delete 0,1 -median 9x9 -normalize -level 0%,40% -threshold 60% z.jpg
Of course, you can diddle around with the numbers and levels, but there may be a couple of ideas in there that you can develop... in OpenCV or ImageMagick.

How to replace white background color with transparent of an image in ImageMagick?

I have an image in .jpg format with white background color. I want to remove the white background color to transparent in Imagemagick. I tried many ways but still the white background can not be removed. Can some one help me to solve this.
You cannot have transparent background colors in your JPEGs. The JPEG file format doesn't support transparency.
If you need transparent background, you need to convert the JPEG to
either PNG (high quality, filesize possibly larger than JPEG)
or GIF (in case you can tolerate low quality and a range of maximally 255 colors).
Example command:
convert your.jpg -transparent white your.png
First, you need to convert the image format from .jpg to .png format, because JPEG does not support transparency. Then use this command:
convert image1.png -fuzz 20% -transparent white result.png
The -fuzz option allows the specified percentage deviation from the pure white colour to be converted to transparent as well. This is useful, for example, when your image contains noise or subtle gradients.
I just found a very neat thing!
magicwand 1,1 -t 20 -f image -r outside -m overlay -o 0 image.jpg imgOutput.png
It is a Fred Weinhaus bash script that can be downloaded from here (for non commercial use only). Also there has about 250 scripts!! and this one is amazing! it did exactly the trick, to remove all background while keeping the inner image dots untouched!
At his page, there are several images as examples so you pick what you need to put on the command line!
The initial position 1,1 is a general guesser saying all the contour is background.
Pay attention that the output must be ".png"
This is my solution without magicwand (replace magick by convert for im < 7.0):
magick img.png -fuzz 20% -fill none -draw "alpha 1x1 floodfill" result.png
Get the background automatically and remove it :
bg=$(convert input.png -format "%[pixel:p{0,0}]" info:)
convert input.png -fuzz 20% -transparent "$bg" output.png

Resources