Saturday, May 11, 2013

IMAGE CONVERSION

Unknown | 4:55 PM |

Convert image to binary image, based on threshold

X=imread(‘trees.tif’);
BW = im2bw(X, map,0.4);
subplot(1,2,1), subimage (X), subplot(1,2,2), subimage (BW);



clip_image002



Global image threshold using Otsu's method


I = imread('cameraman.tif');
level = graythresh(I);
BW = im2bw (I, level);
subplot(1,2,1), subimage (I), subplot(1,2,2), subimage (BW);

clip_image004


CONVERT RGB image or colormap to grayscale


I = imread('peppers.png');
J = rgb2gray(I);
subplot(1,2,1), subimage (I), subplot(1,2,2), subimage (J);


clip_image006

Convert grayscale or binary image to indexed image

I = imread('cameraman.tif');
[X, map] = gray2ind(I, 16);
subplot(1,2,1), subimage (I), subplot(1,2,2), subimage (X,map);


clip_image008


Convert RGB image to indexed image

RGB = imread('peppers.png');
[X,map] = rgb2ind(RGB,128);
subplot(1,2,1), subimage (RGB), subplot(1,2,2), subimage (X,map);

clip_image010



Convert indexed image to grayscale image

X=imread(‘trees.tif’);
I = ind2gray(X,map);
subplot(1,2,1), subimage (X,map), subplot(1,2,2), subimage (I);

clip_image012




Convert indexed image to RGB image

X=imread(‘trees.tif’);
I = ind2rgb(X,map);
subplot(1,2,1), subimage (X,map), subplot(1,2,2), subimage (I);

clip_image014


Convert grayscale image to indexed image using multilevel thresholding

I = imread('snowflakes.png');
X = grayslice(I,16);
subplot(1,2,1), subimage(I),subplot(1,2,2),subimage(X,jet(16))

clip_image016



Convert matrix to grayscale image

I = imread('rice.png');
J = filter2(fspecial('sobel'),I);
K = mat2gray(J);
subplot(1,2,1), subimage(I),subplot(1,2,2),subimage(K)

clip_image018

No comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Search

Infolinks In Text Ads

Total Pageviews

Subscribe here

Enter your email address:

Delivered by FeedBurner