Write partial image data to small file PPM?

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
yellow
Posts: 28
Joined: 2011-06-15T14:01:24-07:00
Authentication code: 8675308

Write partial image data to small file PPM?

Post by yellow »

hi

Is it possible to analyse an image, locate the pixel values which are in levels 255 down to 200 in each channel and write them to either a text file with coordinates and pixel value, assume from reading done so far PPM and that has no resolution, just a list of coords and pixel values or image format with no resolution to save memory space, then the corresponding method to recreate an image of correct pixel dimensions displaying only the pixel values in the 255 to 200 range positioned correctly as orginally analysed with either black or white for all other pixels below 200?

May seem a long winded way to get that 255 to 200 range but this is with regard to an image capturing device, looking to capture minimum data needed to device memory and then recreation of that data in a full resolution image frame, (with missing data) later.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Write partial image data to small file PPM?

Post by fmw42 »

You can capture the pixels by converting to txt: format and filtering the text for your 255 to 200 range. However, I do not know how you would put them back into an image as they are at random locations. Perhaps you could take your list of points and use -draw "point ..." to put them back into a transparent image of your original size.

see
http://www.imagemagick.org/Usage/files/#txt
and
http://www.imagemagick.org/Usage/draw/#primitives

However, there are much faster ways to convert your input image into an image that shows only your desired pixels and has a transparent background. This is just thresholding and converting the rest to transparent.

convert image -black-threshold XX -transparent black result

use XX=200 on 8-bit (Q8) compile or XX=100*200/255% in Q16 or XX=65535*200/255 as raw value
Post Reply