[Index for tmp_for_tar/vrml.doc] [Return to Master Index]

rgb2gray

(tmp_for_tar/vrml.doc/rgb2gray.m)


Function Synopsis

gr = rgb2gray( rgb )

Help text

       gr = rgb2gray( rgb ) - convert rgb to graylevel.

 Convert a rgb pixmap or image structure to graylevel

 gr   : H x W   or image structure
 rgb  : H x 3W  or image structure

 Last modified: December 2000



Listing of function file tmp_for_tar/vrml.doc/rgb2gray.m

##       gr = rgb2gray( rgb ) - convert rgb to graylevel.
##
## Convert a rgb pixmap or image structure to graylevel
##
## gr   : H x W   or image structure
## rgb  : H x 3W  or image structure

## Author:        Etienne Grossmann  <etienne@isr.ist.utl.pt>
## Last modified: December 2000

function gr = rgb2gray( rgb )
if ! is_struct (rgb),
  W3 = columns (rgb) ;
  gr = floor ( (rgb(:,1:3:W3) + rgb(:,2:3:W3) + rgb(:,3:3:W3))/3 ) ;
else
				# Don't convert a gray image
  if rgb.rgb,    gr.im = rgb2gray (rgb.im);
  else           gr.im = rgb.im ;
  end
  gr.rgb = 0 ;
  gr.maxval = rgb.maxval ;
end

Produced by oct2html on Sat Dec 2 19:08:39 2000
Cross-Directory links are: ON