Please can someone help me out with this code?
Mostra commenti meno recenti
This code is giving me error message (FUNCTION keyword use is invalid here, this might cause later message about END).
df=findobj('tag', 'edit3 ');
sdf=get( df,'string');
fg=['c:/users/gabs/documents/matlab/Segmented' sdf];
vv =imread(fg);
if ndims(vv)==3
I=rgb2gray(vv);
else
I=vv;
end
vv=I;
N = normalise(vv,O,l); % normalise to have zero mean, unit std dev
yu=['Originallmage:', sdf];
po=['c:/users/Deji/documents/matlab/Normalized ',sdf];
imwrite(N,po );
%subplot(1 ,2,1), imshow(I,'initialmagnification' ,215), title(yu);
imshow(N),title(strcat(po ));
% This function normalizes the image to desired mean of 0 and variance of 1
function gb = normalise(image,desiremean,desirevar)
if ~(margin == 1 || margin == 3)
error('No of arguments must be 1 or 3');
end
if margin == 1 % Normalisc 0 - 1
ifndims(image) ~= 3; % Assume colour i.mage
else % Normalise to desired mean and variance
if ndims(image) == 3 % colour image?
error('cannot normalise colour image to desired mean and variance');
end
if ~isa(dsafimage,'double')
image = double(image);
end
image = image - mean(image(:));
image = image/std(image(:)); % Zero mean, unit std dev
gb = desiremean + image*sqrt(desirevar);
end
Risposte (2)
Matt Fig
il 16 Ago 2012
0 voti
Where is this code located? If you have it in a script or at the command line, that would explain why you get that error.
Azzi Abdelmalek
il 16 Ago 2012
save this function
function gb = normalise(image,desiremean,desirevar)
if ~(margin == 1 || margin == 3)
error('No of arguments must be 1 or 3');
end
if margin == 1 % Normalisc 0 - 1
ifndims(image) ~= 3; % Assume colour i.mage
else % Normalise to desired mean and variance
if ndims(image) == 3 % colour image?
error('cannot normalise colour image to desired mean and variance');
end
if ~isa(dsafimage,'double')
image = double(image);
end
image = image - mean(image(:));
image = image/std(image(:)); % Zero mean, unit std dev
gb = desiremean + image*sqrt(desirevar);
end
then run this part of your code
df=findobj('tag', 'edit3 ');
sdf=get( df,'string');
fg=['c:/users/gabs/documents/matlab/Segmented' sdf];
vv =imread(fg);
if ndims(vv)==3
I=rgb2gray(vv);
else
I=vv;
end
vv=I;
N = normalise(vv,O,l); % normalise to have zero mean, unit std dev
yu=['Originallmage:', sdf];
po=['c:/users/Deji/documents/matlab/Normalized ',sdf];
imwrite(N,po );
%subplot(1 ,2,1), imshow(I,'initialmagnification' ,215), title(yu);
imshow(N),title(strcat(po ));
1 Commento
Walter Roberson
il 16 Ago 2012
The function should be saved in the file normalise.m
Categorie
Scopri di più su Image Transforms in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!