現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
2012 年 9 月 20 日
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
2012 年 9 月 20 日
can you show me a format of writing statements for image display as example?
Adela
2012 年 9 月 20 日
if i need to do more conversion instead of only gray scale, i will need more output arguement?
Sabarinathan Vadivelu
2012 年 9 月 20 日
Yes. If your function returns how many variables will be the number of output arguments.
This probably reads the inputImage and displays an Image.
A = imread ('input.jpg');
figure, imshow(A);
Adela
2012 年 9 月 20 日
can you carry on with the code you gave above with converion from garyscale to binary as example?
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
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?
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
2012 年 9 月 20 日
yeap! i know that function. but how do i put it together witht the previous code?
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
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
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
2012 年 9 月 21 日
what do you mean by axes??
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
2012 年 9 月 21 日
so i'll have to plot my image?
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 Exchange で Images についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
