map bright r and b pixels and negate rest of 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
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

map bright r and b pixels and negate rest of image?

Post by geoland »

Code: Select all

convert rose: -colorspace rgb -colors 256 -depth 8 -format "%c" histogram:info:

color="( *137, *168, *119)"
convert rose: -colorspace rgb -colors 256 -depth 8 txt: | \
grep "$color" | cut -d: -f1
http://www.imagemagick.org/Usage/color_basics/#zeroing

I gleaned the code above from fwm42 Fred's site with a view to modifying a tiff image by zeroing all but the very bright blue and red pixels. This would be used to subtract matching pixels from other images from the same camera, without subtracting any other features.

Having identified the blue and red values to be retained the rest of the image would be negated, including the alpha channel.

Is this doable in IM? If so it will make a very useful template or map of hot and cold pixels. Not sure where to start?
Last edited by geoland on 2016-06-12T02:03:58-07:00, edited 1 time in total.
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: map bright r and b pixels and negate rest of image?

Post by snibgo »

Your commands are a little strange. The first has no output, and the last pipes to nowhere.
geoland wrote:Is this doable in IM?
Certainly. From a map of known "hot" pixels, you could turn those pixels transparent then use a hole-filling technique to fill them.
snibgo's IM pages: im.snibgo.com
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: map bright r and b pixels and negate rest of image?

Post by geoland »

Not sure what happened there. Corrected in post.
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: map bright r and b pixels and negate rest of image?

Post by Bonzo »

I wrote some code to remove hot pixels from a photo and changed the hot pixel ( plus surrounding ones ) to transparent I then composited it over a blurred version of the same image. This worked well but obviously you need to do it before the image is cropped or resized and you would need a map for all the possible orientations. In the end I did it manually in a photo editing program as my hot pixels only showed up at certain ISO/exposure values.

It is interesting if you take a long exposure with the lens cap on there is a great variation in the pixel colours. I suppose it is impossible to get every pixel to be exactly the same.
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: map bright r and b pixels and negate rest of image?

Post by geoland »

I'm not sure how to tackle this but the operation will be on the final image and orientation will not be an issue.

The colour and intensity of the offending pixels is significantly brighter than the remainder of the image. If the hot pixels are mapped and averaged to the surrounding pixels using interpolation / morphology, a disk of some sort, loosely speaking, that might work. http://www.imagemagick.org/Usage/morphology

The process needs to be reasonably quick. In Linux jpeghotp quickly maps hot pixels and jpegpixi fixes them. Something similar for tiff images would be very handy. I will have a look at the code and see if it can work with tiff files.
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
Post Reply