[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Color Image to grayscale image

From: Richardson, Anthony
Subject: RE: Color Image to grayscale image
Date: Mon, 10 Jun 2019 14:01:08 +0000

> Subject: Color Image to grayscale image
> I have a color image that I'm trying to convert to grayscale, I use the code 
> below but the image is still in color.
> grayimage=mat2gray(colorimage);
> imshow(grayimage)
> My goal is:
> 1) To convert a color image into grayscale 
> 2) Then place the intensity / brightness of each grayscale pixel into a range 
> between 0-1
> I'm using Octave 4.2.2 Ubuntu 64bit 18.04

Try rgb2gray instead of mat2gray.  Mat2gray is intended for converting matrices 
(2D arrays) to grayscale images, not converting color images (3D arrays) to 
grayscale images.


Rgb2gray will return a floating point image if the input image is floating 
point.  It will return an integer image if the input image is integer.  You 
will need to convert and scale to get the desired image type in that case.

Tony Richardson

reply via email to

[Prev in Thread] Current Thread [Next in Thread]