フィルターのクリア

C function in Matlab [Mex-file]

2 ビュー (過去 30 日間)
Esther
Esther 2012 年 9 月 13 日
Can someone help me with C function in Matlab? I did these code and my professor wanted me to do in C function in matlab. And is there any good websites that i can learn about matlab functions etc too? thank you.
I = imread('C:\OUTDOOR\456kg.jpg'); %read the image
subplot(3,3,1);imshow(I);
gray = rgb2gray(I); %convert to grayscale
subplot(3,3,2); imshow(gray)
u=fspecial('unsharp',1);
pu=filter2(u,gray);
subplot(3,3,3); imshow(pu/255)
Binary = pu<24; %find a suitable threshold
subplot(3,3,4); imshow(Binary)
Binary = ~Binary; %complement the image
subplot(3,3,5); imshow(Binary)
imwrite(Binary, 'C:\INDOOR\456kgnew.jpg','jpg')
I=imread('C:\INDOOR\456kgnew.jpg'); %read the image
J = imread('C:\INDOOR\456kgnew.jpg');
K = imnoise(J,'salt & pepper',0.02);
L = medfilt2(K);
subplot(3,3,6); imshow(L);
[EDITED, Jan, code formatted]
  2 件のコメント
Jan
Jan 2012 年 9 月 13 日
As long as you do not ask a qeustion, it is hard to help. What is the problem?
Esther
Esther 2012 年 9 月 13 日
my professor wanted me to write in functions. which i do not get what he means too. maybe like C programming?

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

回答 (1 件)

Jan
Jan 2012 年 9 月 13 日
編集済み: Jan 2012 年 9 月 13 日
A function has its own "workspace", which is the set of locally known variables. As explained in the documentation exhaustively (reading the "Getting Started" chapters is recommended!), your can write a function like this:
function [output1, output2, ...] = FunctionName(input1, input2, ...)
"Scripts" are similar, but do not have the above line and they share the workspace of the calling function or script.
For your example:
function MyDisplayFunction(FileName)
I = imread(FileName)
...
Then this is called from the command window or any other function as:
MyDisplayFunction('C:\OUTDOOR\456kg.jpg')
  2 件のコメント
Esther
Esther 2012 年 9 月 13 日
Jan
Jan 2012 年 9 月 13 日
I thought of http://www.mathworks.com/help/matlab/getting-started-with-matlab.html or the correcponding chapters in your local docs.

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by