You may use MATLAB to visually display the input and output files and demo outpu
ID: 3829406 • Letter: Y
Question
You may use MATLAB to visually display the input and output files and demo output. Matlab commands g imread ('c: Aloc image ext') read the image Scheck to see the size of the image size ig) g rgb2 gray (g) Sapply this is he image is 3-D matrix (3rd dimension is color 7e (g) et dimension in m and g g randn (m, n) Sadd some white noise to the image g reshape (g, 1, m*n); Sreshapes matrix into a vector append to row col to the vector fid fopen imagefile 'w'); Simage file is the name of the file Sw-open for writing fwrite (fid g, uinL8'); ss Lore into file a unsigned b e close (fid) display regular images g mre ad picture ext. read image images (g) display $show as black /white colormap (grayscale) If you want to display the contents of your file pre/post processing: sopen file for eading fid fopen img 'r') rc fread (fid, 2) Sread firs 2 by Les (row, col) Sread the stored vector of size rxc y fread (fid, rc (1)*rc (2)); reshape (y, 200, 200 i sreshape vector into a matrix imagesc (y') s display colormap (grayscle) fclose (fid)Explanation / Answer
Executable Code:-
clc;
clear all;
r=imread('c:locimage.ext');
size(r)
r=rgb2gray(r);
[x y]=size(r); % This line you have to add
[l m]=size(gr;
r=r+uint8(randn(x,y));
r=reshape(r,1,x*y);
r=[l m r];
tid=topen('imagefile','s');
twrite(tid,r,'uint8');
tclose(tid);
tid=topen('imagefile','v');
lm=tread(tid,2);
z=tread(tid,lm(1)*lm(2));
z=reshape(z,lm(1),lm(2));
imagesc(z)
tclose(tid)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.