Basics: 1. Write A MATLAB Code To Read, Show and Write Image
Basics: 1. Write A MATLAB Code To Read, Show and Write Image
BASICS
1. Write a MATLAB code to Read, Show and Write Image.
clc;
clear all;
close all;
img = uigetfile('*.jpg','Select Image')
a=imread(img);
imshow(a);
imwrite(a,'ohm.jpg');
R=a(:,:,1);
G=a(:,:,2);
B=a(:,:,3);
for i=1:1:600
for j=1:1:800
GRAY(i,j)=(0.3*R(i,j))+(0.59*G(i,j))+(0.11*B(i,j));
end
end
Method 2: Averaging
GRAY=(R+G+B)/3;
GRAY=(0.3*R)+(0.59*G)+(0.11*B);
Experiment 0
BASICS
GRAY=rgb2gray(a);
imshow(GRAY);