Understanding of Matlab (image processing)

Hi. Currently i am doing a proj of image processing. i was told to create a funtion-m file with the function,arguements to display any image etc. but i do not know what are the input and output arguments i should put to display my image? I have tried studying/viewing from lots of videos to understand it but almost all explanation in arguments uses 'points'. I should plot my image first to do the function part? I am really confused, i hope any of you can give a simple explanation for me[ using codes etc ] to let me understand better. [ new to matlab ] thank you very much.

 採用された回答

Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012 年 9 月 20 日

0 投票

There is an advantage in MATLAB that when a function is created, it can be used as a command in another file. say for example,
%Type this in one file
A=imread('input.jpg'); % Reads input Image
B = imagedisplay(A); % Call the function image display
% Here A, input argument, B output argument
figure, imshow(B);
-------------------------------------------------
%Type this in other file
function [output_img] = imagedisplay(input_img)
output_img = rgb2gray(input_img);
--------------------------------------------------
This function returns an image called ' output_img' and that is displayed in the main program.

16 件のコメント

Adela
Adela 2012 年 9 月 20 日
can you show me a format of writing statements for image display as example?
Adela
Adela 2012 年 9 月 20 日
if i need to do more conversion instead of only gray scale, i will need more output arguement?
Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012 年 9 月 20 日
Yes. If your function returns how many variables will be the number of output arguments.
Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012 年 9 月 20 日
This probably reads the inputImage and displays an Image.
A = imread ('input.jpg');
figure, imshow(A);
Adela
Adela 2012 年 9 月 20 日
can you carry on with the code you gave above with converion from garyscale to binary as example?
Adela
Adela 2012 年 9 月 20 日
編集済み: Adela 2012 年 9 月 20 日
where do i call to display the image? & may i know what method of funtion is this? As matlab offers several different types of function. thank you:)
Adela
Adela 2012 年 9 月 20 日
'Yes. If your function returns how many variables will be the number of output arguments.'
- what if i have to use the first output image to covert binary image?
Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012 年 9 月 20 日
For converting a gray image to binary image you can use this function.
BW = im2bw (I, level);
Here I gray scale image, BW represents the Binary image. As we know that binary image consists of pixel values 0 and 1 only. In a gray scale image pixel values varies from 0 to 255. So 'level' indicates the threshold value.
pixel values greater than level will be assigned with 1.
pixel values lesser than level will be assigned as 0.
Adela
Adela 2012 年 9 月 20 日
yeap! i know that function. but how do i put it together witht the previous code?
Mark Hayworth
Mark Hayworth 2012 年 9 月 20 日
Don't you think it would simply be
%Type this in other file
function [output_img] = imagedisplay(input_img)
output_img = rgb2gray(input_img);
output_img = im2bw(output_img);
Adela
Adela 2012 年 9 月 21 日
thanks! but what do i do if i want to display grayscale and binary in main program at the same time?
Image Analyst
Image Analyst 2012 年 9 月 21 日
Well, I'd have two axes and call imshow() to display each image in the desired axes. Does that make sense?
Adela
Adela 2012 年 9 月 21 日
what do you mean by axes??
Image Analyst
Image Analyst 2012 年 9 月 21 日
Oh boy, looks like you need to read the getting started section of the help or look at Doug Hull's tutorial blogs on MATLAB Central. An axes is one of the most basic controls, probably second only to a push button. It's a box on the GUI where you display your results, whether it's a line plot, a bar or pie chart, an image or whatever.
Adela
Adela 2012 年 9 月 21 日
so i'll have to plot my image?
Image Analyst
Image Analyst 2012 年 9 月 21 日
Are you playing with me? Don't you recall that you asked " where do i call to display the image"? Scroll up if you don't. So why do you ask " so i'll have to plot my image?"
And I never said "plot" your image, I said display it with imshow(). But I don't care one way or another what you do with your images - if you display them or not. That's your decision.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by