Azzera filtri
Azzera filtri

C function in Matlab [Mex-file]

2 visualizzazioni (ultimi 30 giorni)
Esther
Esther il 13 Set 2012
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 Commenti
Jan
Jan il 13 Set 2012
As long as you do not ask a qeustion, it is hard to help. What is the problem?
Esther
Esther il 13 Set 2012
my professor wanted me to write in functions. which i do not get what he means too. maybe like C programming?

Accedi per commentare.

Risposte (1)

Jan
Jan il 13 Set 2012
Modificato: Jan il 13 Set 2012
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')

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by