任意图像转换灰度图像 matlab

%-- Converts image to one channel (grayscale) double
function img = im2graydouble(img)    
  [dimy, dimx, c] = size(img);
  if(isfloat(img)) % image is a double
    if(c==3)
      img = rgb2gray(uint8(img));
    end
  else           % image is a int
    if(c==3)
      img = rgb2gray(img);
    end
    img = double(img);
  end

你可能感兴趣的:(c,image,matlab,IM)