Filters Main Function in Image Processing

1 visualizzazione (ultimi 30 giorni)
Rooter Boy
Rooter Boy il 17 Nov 2020
I want to applied this three filter to a gray level image.
After that i want to save this image with using this file names (imsobel, imlaplas) in same current file.
I tried this but i can't do this.
I need a main fucntion.
%img =imread('cameraman.tif');
%Sobel filters
%Sx=[-1 0 1; -2 0 2; -1 0 1]
%Sy=[-1 -2 -1; 0 0 0; 1 2 1]
%T1=imfilter(img, Sx)
%T2=imfilter(img, Sy)
%imshow(T1)
%imshow(T2)
%Laplacian filters
&H= [0, -1, 0; -1, 4, -1; 0, -1, 0];
&T=imfilter(img, H)
%imshow(T)
% "imagefiles" variable contails each file detail (e.g. filename, size, etc.)
imagefiles = dir(['C:\Users\metec\Desktop\aa\', '*.tif']);
% Count total number of files
nfiles = length(imagefiles);
% Display total number of the files
disp(['Total number of file: ', num2str(nfiles)])
% Define filter kernel
%Laplacian filters
H = [0, -1, 0; -1, 4, -1; 0, -1, 0];
T=imfilter(img, H)
%imshow(T)
for idx = 1:nfiles
T=imfilter(img, H)
% Display name of each file
disp(imagefiles(idx).name)
currentfilename = [imagefiles(idx).folder , '\', imagefiles(idx).name];
currentimage = imread(currentfilename);
% Apply filter to current image using convn
result = convn(currentimage, T, 'same');
% Save the filtered image
imwrite(uint8(result),...
['C:\Users\metec\Desktop\aa\', 'imgLaplas', imagefiles(idx).name, '.tif'])
end

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by