Search code examples
matlabimshow

store imshow - Matlab


How can I store the reduced color imshow in an image object so I can further use it for other analysis.

Source:

I =  imread('C:\eg.jpg');

[X_no_dither,map]= rgb2ind(I,8,'nodither');
figure, imshow(X_no_dither,map)

Solution

  • You can use ind2rgb to convert it back to an RGB image using your new indexed image and colormap

    rgb_image = ind2rgb(X_no_dither, map);
    

    If you want, you can then save this resulting image to a file with imwrite

    imwrite(rgb_image, 'newimage.png')