Convert from JPG to RGB, averaging the missing pixels

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
RigTig

Convert from JPG to RGB, averaging the missing pixels

Post by RigTig »

Converting from JPG to RGB adds lots of black pixels. What I want is each black pixel to be an 'average' of the nearby pixels, except other black ones. The intention is to use the RGB for further mathematical manipulation, and my cameras all produce JPGs.

Replacement of the black with a single colour is easy:

Code: Select all

convert a.jpg -size 2000x3000 -depth 32 b.rgb
convert -size 2000x3000 -depth 32 b.rgb fill white -opaque black -size 2000x3000 -depth 32 c.rgb
-adaptive-blur looks potentially useful, but does not know how to ignore the nearby black pixels; and, if the pixel is not black, then I'd rather not blur it.

Masking looks like a way to go, but I cannot figure out the details. Any ideas welcome, thank you.

RigTig
RigTig

Re: Convert from JPG to RGB, averaging the missing pixels

Post by RigTig »

Forget this question. Not reproducible!!

I went back and started all over from the original JPGs, and there are NO black pixels in the RGB file using

Code: Select all

convert A.JPG -evaluate multiply 0.6 -size 2000x3000 -depth 32 -define quantum:format=floating-point bf.rgb
even though that is what (I thought) I used before.

ImageMagick is somehow smart enough to 'fill in the gaps' from the lossy JPG to RGB. Yippee! :D
Post Reply