フィルターのクリア

How to make a vector of multiple images in double form by using function?

1 回表示 (過去 30 日間)
Hamza Zaheer
Hamza Zaheer 2018 年 11 月 24 日
コメント済み: Jan 2018 年 11 月 26 日
clc;
clear all;
close all;
for i=1:10
c{i}=imread(sprintf('s%d.jpg',i));
w = rgb2gray(c{i});
im = imresize(w,0.25);
mi = double(im);
q= im2vec(mi);
J = imnoise(mi,'salt & pepper')
figure,
imshow(mi)
medianFilteredImage = medfilt2(mi, [50 50]);
figure,
%imshow(medianFilteredImage)
% Find the noise. It will have a gray level of either 0 or 255.
noiseImage = (mi == 0 | mi == 255);
% Get rid of the noise by replacing with median.
noiseFreeImage = noiseImage; % Initialize
noiseFreeImage(noiseImage) = medianFilteredImage(noiseImage); % Replace.
imshow(noiseFreeImage);
end
%Function
function mi=im2vec(im)
[N M]=size(im);
% for i=1:N
% for j=1:N
% mi((i-1)*N+j)=im(i, j);
% end
% end
for i=1:N
mi(1, (i-1)*M+1:M+(i-1)*M)=im(i,:);
end
  1. Use rgb2gray command.
  2. Resize to size 50x50 (using imresizecommand).
  3. Make a vector (function is provided, also make it in double form).
  4. Add salt and pepper noise.
  5. Display noisy images.
  6. Remove the noise using a suitable filter.
  7. Display the noise free images.
  3 件のコメント
Hamza Zaheer
Hamza Zaheer 2018 年 11 月 26 日
編集済み: Hamza Zaheer 2018 年 11 月 26 日
No, the code does not solve my problem. My actual question is that, I have to read ten images in a loop and make the following changes to the images.I am attaching the images and the function mentioned in point #3 . Thanks in advance!
  1. Use rgb2gray command.
  2. Resize to size 50x50 (using imresizecommand).
  3. Make a vector (function is provided, also make it in double form).
  4. Add salt and pepper noise.
  5. Display noisy images.
  6. Remove the noise using a suitable filter.
  7. Display the noise free images.
Jan
Jan 2018 年 11 月 26 日
So is all you want to convert:
mi = double(im);
to
mi = double(im(:));
? What exactly is your quiestion? Attaching the images does not clear this detail.

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by