Mercurial > octave-nkf
view scripts/image/rgb2ind.m @ 917:b843a65fa977
[project @ 1994-11-11 02:00:28 by jwe]
author | jwe |
---|---|
date | Fri, 11 Nov 1994 02:06:42 +0000 |
parents | 3470f1e25a79 |
children | 56520a75b5b3 |
line wrap: on
line source
function [X map] = rgb2ind(R,G,B) # Convert and RGB image to an octave indexed image. # # [X map] = rgb2ind(R,G,B) # # SEE ALSO: ind2rgb, rgb2ntsc. # # Bugs: The color map may have duplicate entries. if(nargin != 3) usage ("[X, map] = rgb2ind(R,G,B)"); endif [hi wi] = size(R); X = zeros(hi,wi); map = zeros(hi*wi,3); pref = do_fortran_indexing; unwind_protect do_fortran_indexing = "true"; map(:,1) = R(:); map(:,2) = G(:); map(:,3) = B(:); X(:) = 1:(hi*wi); unwind_protect_cleanup do_fortran_indexing = pref; end_unwind_protect endfunction