Color-Pixel-Image

Color images are represented by color-pixel-image objects which have three pixel-image objects to represent red, green, and blue components in RGB representation, or hue, lightness, and saturation components in the HLS model. Conversion between RGB and HLS is supported.




color-pixel-image [class]


  :super   propertied-object 

:slots width height component1 component2 component3


represents color images with three pixel-image objects.


:width [method]

returns the width of this image.


:height [method]
returns the height of this image.


:size [method]
returns $width \times height$ of this image.


:red [method]
returns component1.


:green [method]
returns component2.


:blue [method]
returns component3.


:hue [method]
returns component1. A hue value between 0 and 360 is represented by a byte value between 0 and 255.


:lightness [method]
returns component2. The normalized brightness values (0..1) are mapped into integers between 0 and 255.


:saturation [method]
returns component3. The normalized saturation values (0..1) are mapped into integers between 0 and 255.


:pixel x y [method]
returns a list of three integers each of which is taken from component1, component2 and component3 at (x,y). This triplet can be interpreted either as RGB values or HLS values.


:monochromize &optional (NTSC nil) [method]
computes brightness from RGB components and returns a new pixel-image. If NTSC is nil, $(R+G+B)/3$ is computed. If T, $0.299*R+0.587*G+0.114*B$ is computed.


:HLS [method]
assuming this image is representing an RGB image, converts the image into HLS representation. RGB2HLS is called for the conversion of each pixel.


:RGB [method]
assuming this image is representing an HLS image, converts the image into RGB representation. HLS2RGB is called for the conversion of each pixel.


:halve [method]
returns color-pixel-image that is shrunk into half-size image.


:display &optional (win *color-viewer*) [method]
displays this color-pixel-image in a xwindow designated by win by using :putimage. Each pixel value is referred as a index in x's color map. To get a desired appearance, this pixel-image must have been translated by proper LUTs.


:display-lut &optional (newlut1) (newlut2 newlut1) (newlut3 newlut2) [method]
sets look-up tables newlut1, newlut1 and newlut1 as display-lut, respectively. Then translates this image using this look-up table and sets translated pixel-image object as xpicture.



\begin{emtabbing}
{\bf :edge1}
\it\&optional \=(method 1) \\lq [method]\\
\>(th1 ...
...ld*)\\
\>(run *edge-length-threshold*) (win *color-viewer*)
\rm
\end{emtabbing}
detects edge of this image. And displays this edge on this image.


:hex &optional (x 0) (y 0) (w 16) (h 16) (strm t) [method]
prints pixel data in the specified rectangular region in the hexadecimal format.


:hex1 &optional (x 0) (y 0) (w 64) (h 16) (strm t) [method]
prints pixel data in the specified rectangular region in the hexadecimal format.


:prin1 strm &rest msg [method]
prints this image-pixel object with its name and dimensions.


:init width height &optional r g b [method]
defines the size of a color image and allocates pixel-images for each color component.


Provided a ppm file, you can extract color (hue) values out of the image and display it in an xwindow by the following program.

(setq ppmimg (read-pnm "xxx.ppm"))
(send ppmimg :hls)   ; RGB to HLS conversion
(make-ximage (send ppmimg :hue) *rainbow32*)

k-okada 2013-05-21