Page 1 of 1
Batch Replace Color Produces Pixelated Colors
Posted: Sun Aug 18, 2013 4:27 am
by jpeni
I am trying to batch convert a collection of black symbols in .PNG (32bit RGB) images.
I select Batch Processing and add the Replace Color Transformations option.
I select the original color and the replacement color and click Go.
The images process, but the replacement color is pixelated - not smooth.
What am I doing wrong?
JPeni
Re: Batch Replace Color Produces Pixelated Colors
Posted: Mon Aug 19, 2013 10:33 am
by DOS386
jpeni wrote:I am trying to batch convert a collection of black symbols in .PNG (32bit RGB) images.
What am I doing wrong?
Please upload the original Corpus Delicti in PNG format. Let me guess that it has more than 1 black colour?
Re: Batch Replace Color Produces Pixelated Colors
Posted: Mon Aug 19, 2013 11:50 am
by cday
DOS386's explanation is probably correct...
If the intention is to batch convert 32bit RGB images of symbols to pure black symbols, it might be logical to batch convert the images to 1-bit colour depth using Transformations > Convert > Convert to Binary.
That does assume that there is no other colour in the source images which needs to be preserved, otherwise it would be an interesting challenge... Maybe using Levels?? Or possibly simply by reducing the number of colours in the PNG??
Re: Batch Replace Color Produces Pixelated Colors
Posted: Mon Aug 19, 2013 7:23 pm
by jpeni
I checked the original RGB 32-bit PNG image - the color is pure black - Value: 0,0,0. The image contains only Black and White.
I converted the PNG image to Binary (No dither) with XnView and reprocessed to Replace Black (0,0,0) with Red (255, 0, 0),
but the resulting Replaced Color symbol is still Black - the Red did not appear.
JPeni
Re: Batch Replace Color Produces Pixelated Colors
Posted: Mon Aug 19, 2013 9:29 pm
by cday
If the image is converted to binary it can't contain anything except black and white. I'm sorry, I didn't realise you wanted to replace the black symbol with a red symbol, although that is in fact clear in your original post.
Can you post the original image, or a representative image, either as an attachment or as a link to a file hosting service, as DOS386 suggested?
Edit:
I have done a quick test with a simple image I created and with 24-bit depth black was replaced by red successfully, but when the same image was converted to 32-bit in XnView the histogram of the resultant 'red' image had some additional colour (which showed in the image as a band rather than pixelation).
If you can post a test image it should be possible to reproduce any bug if there is one for 32-bit depth images.
Re: Batch Replace Color Produces Pixelated Colors
Posted: Tue Aug 20, 2013 12:26 am
by jpeni
Re: Batch Replace Color Produces Pixelated Colors
Posted: Tue Aug 20, 2013 2:00 am
by XnTriq
jpeni wrote:I am trying to batch convert a collection of black symbols in .PNG (32bit RGB) images.
If your goal is to convert these symbols from black to red without loosing the smooth edges, you're better off by just increasing the value of the red channel:
- View mode: Image » Adjust » Brightness/Contrast/Gamma/Balance... » Colour balance
- Batch processing: Map » Colour balance
Would you like the background to be transparent?
Re: Batch Replace Color Produces Pixelated Colors
Posted: Tue Aug 20, 2013 8:56 am
by cday

- a.png (7.9 KiB) Viewed 2437 times
The file as downloaded contains 149 unique colours, as shown by Image > Count colours used, and as predicted by DOS386.

- b.png (7.51 KiB) Viewed 2437 times
The image obtained using
Image » Adjust » Brightness/Contrast/Gamma/Balance... » Colour balance with Red=255, Green=0, Blue=0.
Excellent idea
XnTrig, but the image still contains 143 unique colours. Is there a way to make a pure red image?
Edit:
The extra colours almost all occur on the edges of the symbol and suggest that the image has been anti-aliased at some point. Reducing the colour depth (using Levels with an extreme setting is one way) results in extra pixels becoming visible on the edges, which substantially degrade its appearance.
So at what point was the image anti-aliased? But as adjusting the colour balance seems to produce an acceptable image, and the anti-aliased image has a better appearance, are the extra colours a problem?
Finally, the original 'Replace colour' method does work correctly for 32-bit images with a single colour, and produces a pure red symbol when the image remains a PNG, but saving as a JPG seems to introduce additional colours and the possibility of banding or other artifacts.
Re: Batch Replace Color Produces Pixelated Colors
Posted: Tue Aug 20, 2013 8:15 pm
by XnTriq
cday wrote:Excellent idea XnTrig, but the image still contains 143 unique colours. Is there a way to make a pure red image?
You'll need XnViewMP for that:
- Create an all red image with the same dimensions as p5fo5Lp.png (200×200 pixels) and name it blank.png.
- Invert p5fo5Lp.png (Image » Map » Negative) and save it as mask.png.
- Tools » Batch convert...
- Input » Add files...: blank.png
- Actions » Add action » Image » Add mask: mask.png (Use mask as alpha)

+

=

Re: Batch Replace Color Produces Pixelated Colors
Posted: Wed Aug 21, 2013 12:48 am
by jpeni
cday and XnTriq
Thanks for your help.
JPeni