please guide me how to call a function in matlab codes
1 view (last 30 days)
Show older comments
Please help me how to make it becuse im not getting any result when I run it
% Clear the Variable and the Command window
clc, clear all
function ImageProcessing(); ((((( this function is not working when i run it ))))
% Read the Image
img = imread('DUBAI.jpg');
% Resize the Image
img1 = imresize(img,[256 256]);
% Display the image
figure,
subplot(3,2,[1,2,3,4]),imshow(img),title('Image from my phone')
subplot(3,2,5.5),imshow(img1),title('Original Resized Image')
% Convert the RGB image to greyscale
img2 = rgb2gray(img1); level = graythresh(img2);
% Apply the thresholding for binarization
BW = imbinarize(img2,level);
% Display the greyscale and binary image
figure,
subplot(211),imshow(img2),title('Greyscale Image'),
subplot(212),imshow(BW),title('Binary Image')
% Rotate the images
BW90 = imrotate(BW,90);
img290 = imrotate(img2,90);
img190 = imrotate(img1,90);
img90 = imrotate(img,90);
% Display the rotated images
figure,
subplot(231),imshow(img1),title(' coloured image'),
subplot(232),imshow(img2),title(' Grey image'),
subplot(233),imshow(BW),title(' Binary image')
subplot(234),imshow(img190),title('Rotated coloured image'),
subplot(235),imshow(img290),title('Rotated Grey image'),
subplot(236),imshow(BW90),title('Rotated Binary image')
% Create and apply the filter
h = fspecial('average',3);
img_low = imfilter(img1,h);
I=(1/256)*img2;
c= (1/9) * [-1 -1 -1;
-1 8 -1;
-1 -1 -1];
img_high=conv2(I,c,'same');
% Display the Filtered image
figure,
subplot(2,2,1.5),imshow(img2),title('Grey image')
subplot(2,2,3),imshow(img_high),title('Image after high Filter')
subplot(2,2,4),imshow(img_low),title(['Image after low Filter'])
end
0 Comments
Answers (1)
David Hill
on 27 Oct 2022
Function runs fine.
File='sunrise.jpg';
ImageProcessing(File)
function ImageProcessing(File)
% Read the Image
img = imread(File);
% Resize the Image
img1 = imresize(img,[256 256]);
% Display the image
figure,
subplot(3,2,[1,2,3,4]),imshow(img),title('Image from my phone')
subplot(3,2,5.5),imshow(img1),title('Original Resized Image')
% Convert the RGB image to greyscale
img2 = rgb2gray(img1); level = graythresh(img2);
% Apply the thresholding for binarization
BW = imbinarize(img2,level);
% Display the greyscale and binary image
figure,
subplot(211),imshow(img2),title('Greyscale Image'),
subplot(212),imshow(BW),title('Binary Image')
% Rotate the images
BW90 = imrotate(BW,90);
img290 = imrotate(img2,90);
img190 = imrotate(img1,90);
img90 = imrotate(img,90);
% Display the rotated images
figure,
subplot(231),imshow(img1),title(' coloured image'),
subplot(232),imshow(img2),title(' Grey image'),
subplot(233),imshow(BW),title(' Binary image')
subplot(234),imshow(img190),title('Rotated coloured image'),
subplot(235),imshow(img290),title('Rotated Grey image'),
subplot(236),imshow(BW90),title('Rotated Binary image')
% Create and apply the filter
h = fspecial('average',3);
img_low = imfilter(img1,h);
I=(1/256)*img2;
c= (1/9) * [-1 -1 -1;
-1 8 -1;
-1 -1 -1];
img_high=conv2(I,c,'same');
% Display the Filtered image
figure,
subplot(2,2,1.5),imshow(img2),title('Grey image')
subplot(2,2,3),imshow(img_high),title('Image after high Filter')
subplot(2,2,4),imshow(img_low),title(['Image after low Filter'])
end
0 Comments
See Also
Categories
Find more on Explore and Edit Images with Image Viewer App in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!