0% found this document useful (0 votes)
7 views13 pages

Image Processing Lan4

The document provides a guide on converting images between different formats using MATLAB, including binary, gray, index, and color. It includes specific code examples for each conversion type, demonstrating how to read images and apply conversion functions. The document is structured with sections dedicated to each conversion method, complete with visual output instructions.

Uploaded by

ayhamjahgh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

Image Processing Lan4

The document provides a guide on converting images between different formats using MATLAB, including binary, gray, index, and color. It includes specific code examples for each conversion type, demonstrating how to read images and apply conversion functions. The document is structured with sections dedicated to each conversion method, complete with visual output instructions.

Uploaded by

ayhamjahgh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Table of Contents

convert to binary ................................................................................................................................. 1


convert to gray ................................................................................................................................... 5
convert to index .................................................................................................................................. 8
convert to color ................................................................................................................................. 12

convert to binary
1- gray to binary

gray = imread('cameraman.tif');
figure,imshow(gray)
t_bin = im2bw(gray,0.5);
figure,imshow(t_bin)

2- index to binary

1
[ind cm] =imread('kids.tif');
figure,imshow(ind,cm)
bin = im2bw(ind,cm,0.45);
figure,imshow(bin)

3- color to binary

c = imread('lighthouse.png');

2
figure,imshow(c)
t_bin = im2bw(c,0.6);
figure,imshow(t_bin)

3
4
convert to gray
1 -index to gray

[ind cm] =imread('kids.tif');


figure,imshow(ind,cm)
g = ind2gray(ind,cm);
figure,imshow(g)

5
2- color to gray

color = imread('peppers.png');
figure,imshow(color)
g = rgb2gray(color);
figure,imshow(g)

6
7
convert to index
1- gray to index

gray = imread('cameraman.tif');
figure,imshow(gray)
impixelinfo
[ind cm]= gray2ind(gray,1024);
figure,imshow(ind,cm)
impixelinfo

8
9
2- color to index

c = imread('lighthouse.png');
figure,imshow(c)
impixelinfo
[ind cm] = rgb2ind(c,1101);
figure,imshow(ind,cm)
impixelinfo

10
11
convert to color
index to color

[ind cm] =imread('kids.tif');


figure,imshow(ind,cm)
impixelinfo
color = ind2rgb(ind,cm);
figure,imshow(color)
impixelinfo

12
Published with MATLAB® R2022a

13

You might also like