필터 지우기
필터 지우기

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
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 CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by