Blogger Tips and TricksLatest Tips And TricksBlogger Tricks

Friday, 27 March 2015

Convert images in different format using MATLAB

Convert grayscale or binary image to indexed image

Code:

I = imread('cameraman.tif');
[X, map] = gray2ind(I, 16);
imshow(X, map);

Convert indexed image to grayscale image


Code:


load trees
I = ind2gray(X,map);
imshow(X,map);
figure,imshow(I);


Convert matrix to grayscale image

Code:


I = imread('rice.png');
J = filter2(fspecial('sobel'),I);
K = mat2gray(J);
imshow(I), figure, imshow(K)


Convert grayscale image to indexed image using multilevel thresholding

Code:

I = imread('snowflakes.png');
X = grayslice(I,16);
imshow(I)
figure, imshow(X,jet(16))

No comments:

Post a Comment

Note: only a member of this blog may post a comment.