How can I extract a specified color from an RGB image using Matlab?
There are two parts to this question. First, I assume you have an RGB image file to extract the data from. This file could be output from a camera, scanner, or simply an image you found on the web somewhere. Second, you need to transform the RGB data into a color space, such as CIELAB. To extract the RGB data from an image file, use the Matlab function imread(). Details on this function can be found on this Mathworks page. This is a smart function which looks at a file and determines which procedure to use to read in the data. It will automatically handle jpeg, tiff, gif, and many other image formats. Imread() will usually return a 3D array, M rows, N columns, 3 image planes. For example: myImg = imread(‘myImageFile.jpg’); The RGB coordinates of a pixel are myImg[m,n,1], myImg[m,n,2], myImg[m,n,3], respectively. To extract the actual color of that pixel, you will need more information. If you know the image is from certain scanner or camera, you can derive a characterization for that s
Related Questions
- How can the same image look different on the same color monitor depending on whether I chose RGB/Windows or RGB/Macintosh and also look rather different on the actual mugs?
- How can I extract a specified color from an RGB image using Matlab?
- How do I create a 24-bit RGB color image from a grayscale image?