Remove white pixel

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
v22
Posts: 6
Joined: 2016-03-09T10:06:06-07:00
Authentication code: 1151

Remove white pixel

Post by v22 »

Hello,

I need to compare 2 images and find differences between them using IM command line tool.
I am using the following command, to generate a third comparison image with found differences higlighted in white:

Code: Select all

compare image1.jpg image2.jpg -colorspace Gray -fuzz 85% -compose Src -highlight-color White -lowlight-color Black

The problem is the result-comparison image has 'white noise' (or dots bigger than 1 pixel) even in areas where there are no differences between images.
How can I remove these white 'pixel' from my image, leaving text at the bottom left good? .

Here are sample images:

the comparison image (white text at bottom left is a real difference between images):
https://drive.google.com/file/d/0B5SBtm ... sp=sharing


IM version:

ImageMagick 6.8.7-9 Q8 x86
Windows 7 64-bit


Thank you in advance
Last edited by v22 on 2016-03-15T10:04:12-07:00, edited 3 times in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove white pixel

Post by snibgo »

snibgo's IM pages: im.snibgo.com
v22
Posts: 6
Joined: 2016-03-09T10:06:06-07:00
Authentication code: 1151

Re: Remove white pixel

Post by v22 »

updated first post
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove white pixel

Post by fmw42 »

There must be differences if you get white areas, even if you cannot see them visually. Just a 1 graylevel difference can cause a difference to show.

Also your two images are not the same size. So I am not sure what Imagemagick is comparing.

Perhaps you should upload again and this time show both input images and the corresponding output image.
v22
Posts: 6
Joined: 2016-03-09T10:06:06-07:00
Authentication code: 1151

Re: Remove white pixel

Post by v22 »

How can you say I am comparing different size images If I didn't upload them?

The images I uploaded in my post are:
- the comparison image
- a zoomed-in portion of the comparison image (just to let you see the white pixel I am talking about)

The images I am comparing have instead the same size and I cannot upload them.
I suppose the 'white pixel' difference I see is a difference caused by 'lossy/artifact' nature of JPG.


My question is if I can remove white pixel from an image using IM command line (so AFTER comparing my images), not if I can get a perfect comparison image.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove white pixel

Post by snibgo »

You have uploaded two images. Neither has any white pixels.
snibgo's IM pages: im.snibgo.com
v22
Posts: 6
Joined: 2016-03-09T10:06:06-07:00
Authentication code: 1151

Re: Remove white pixel

Post by v22 »

The second image has something like a 'noise', white pixel/area on a black background
can't you see it?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove white pixel

Post by snibgo »

whitePixel.jpg is greyscale, and the lightest pixel is 206 in a scale of 0 to 255.

I don't understand what you want. You can turn all the pixels black using (eg by "+opaque"). Or you could turn the white pixels black, but there aren't any. Or all the pixels within a given fuzz factor near white.

I don't think you want to "remove" pixels. Perhaps you want to change their colour, or make them transparent, or something.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove white pixel

Post by fmw42 »

How can you say I am comparing different size images If I didn't upload them?
That is the problem. You did not upload your two input images for us to examine. So how can we tell you how to fix the issue if we cannot test ourselves.
v22
Posts: 6
Joined: 2016-03-09T10:06:06-07:00
Authentication code: 1151

Re: Remove white pixel

Post by v22 »

Ok, sorry my question was not clear and I've uploaded the wrong files.

I cannot upload the images I am comparing, but they are not the point since I am not interested in new method to compare images but on a method to modify the comparison image.


Here is the correct comparison image on which I am working on:
https://drive.google.com/file/d/0B5SBtm ... sp=sharing

I would like to remove 'noise' from that image: if you zoom in, you can see 'white pixel/small white' areas.
With 'remove noise' I mean turn 'white pixel' into black (the same color of background), but without removing white text at bottom left.

I tried using -median 3 command, this is the result :
https://drive.google.com/file/d/0B5SBtm ... sp=sharing

The new image has no 'noise' but text is a bit degraded, is there a better way to remove noise leaving text in the original form?
v22
Posts: 6
Joined: 2016-03-09T10:06:06-07:00
Authentication code: 1151

Re: Remove white pixel

Post by v22 »

With "-median 3" I am able to remove 'white pixel', and result with text is acceptable.

I have now another problem, I would like to remove also vertical and horizontal with lines (to remove I mean turn into background color).
An example of vertical line I would like to remove:
https://drive.google.com/file/d/0B5SBtm ... sp=sharing

Any suggetions?
Post Reply