From: Sprinceana on
Here is the load_image function:

I don't know why it doesn't open the photo even if I give it jpg:

load_image.m contains:

function y = load_image(type, n)

% load_image - load benchmark images.
%
% y = load_image(type, n);
%
% type can be
% 'chessboard1', 'boat', 'lena', 'goldhill', 'mandrill', 'maurice'.
%
% Copyright (c) 2004 Gabriel Peyr

if nargin<2
n = 512;
end

type = lower(type);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for the line, can be vertical / horizontal / diagonal / qcq
if strcmp(type, 'line')
eta = 0.1; % translation
gamma = 1/sqrt(2); % slope
elseif strcmp(type, 'line_vertical')
eta = 0.5; % translation
gamma = 0; % slope
elseif strcmp(type, 'line_horizontal')
eta = 0.5; % translation
gamma = Inf; % slope
elseif strcmp(type, 'line_diagonal')
eta = 0; % translation
gamma = 1; % slope
end

r = 0.6; % radius

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch type
case 'chessboard1'
x = -1:2/(n-1):1;
[Y,X] = meshgrid(x,x);
y = (2*(Y>=0)-1).*(2*(X>=0)-1);

case 'square'
x = -1:2/(n-1):1;
[Y,X] = meshgrid(x,x);
y = max( abs(X),abs(Y) )<r;

case {'line', 'line_vertical', 'line_horizontal', 'line_diagonal'}
x = 0:1/(n-1):1;
X = x'*ones(1,n);
if gamma~=Inf
y = (X-eta) - gamma*X' < 0;
else
y = (X'-eta) < 0;
end

case 'disk'
radius = 0.35;
x = 0:1/(n-1):1;
[Y,X] = meshgrid(x,x);
center = [0.5, 0.5]; % center of the circle
y = (X-center(1)).^2 + (Y-center(2)).^2 < radius^2;

case 'quarterdisk'
radius = 0.95;
x = 0:1/(n-1):1;
[Y,X] = meshgrid(x,x);
center = -[0.1, 0.1]; % center of the circle
y = (X-center(1)).^2 + (Y-center(2)).^2 < radius^2;

case '3contours'
r1 = 1.3;
ct1 = [-1, 1];
r2 = 0.8;
ct2 = [0, 0];
x = 0:1/(n-1):1;
[Y,X] = meshgrid(x,x);
f1 = (X-ct1(1)).^2 + (Y-ct1(2)).^2 < r1^2;
f2 = (X-ct2(1)).^2 + (Y-ct2(2)).^2 < r2^2;
y = f1 + 0.5*f2.*(1-f1);

otherwise
y = imread( [type, '.jpg'] );
y = double(y);
if n~=size(y, 1)
y = image_resize(y,n,n);
end
end

y = double(y);
From: Sprinceana on
Thanks wayne!

The weird thing is that even if I have load_image.m function it gives me this error:

??? Undefined function or method 'load_image' for input arguments of type 'char'.

n = 256; % size of the image
M = load_image('photo_grey', n);
clf;
imageplot(M);

And it should display my grayscale image. I don't know in fact the source of this error.
From: Sprinceana on
Full code haar_tran.m

% haar 2d transform



% read the RGB image

% RGB = imread('102.jpg');
% imshow(RGB);
% title('This is the 102.jpg picture in RGB mode');

% % read the grayscale image

% I = rgb2gray(RGB); % convert to grayscale
% figure,imshow(I);
% title('This is the 102.jpg picture in GRAYSCALE mode');



n = 256; % size of the image
M = load_image('photo_grey', n);
clf;
imageplot(M);


% path to the images
% name = 'photo_grey';
% n = 256;
% M = load_image(name, []);
% M = rescale(imCrop(M,n));



% comment faire le load de l'image grayscale nomme photo_grey?

%n = 256; % n is the number of gray levels in an image that is grayscale
%M = rescale(load_image(name, []) ); % load the image that is already grayscale

%Initialize the transformed coefficients as the image itself and set the initial scale as the maximum one.
%MW will be iteratively transformated and will contains the coefficients.

MW = M;
j = log2(n)-1;

%Select the sub-part of the image to transform.

A = MW(1:2^(j+1),1:2^(j+1));

%Compute average and differences along the vertical direction.

Average_vert = ( A(1:2:size(A,1),:) + A(2:2:size(A,1),:) )/sqrt(2);
Differences_vert = ( A(1:2:size(A,1),:) - A(2:2:size(A,1),:) )/sqrt(2);

%Concatenate them in the vertical direction to get the result.

A = cat3(1, Average_vert, Differences_vert );

% Display the result of the vertical transform.

%clf; % clear figure
imageplot(M,'Original image',1,2,1);
imageplot(A,'Vertical transform',1,2,2);

% Compute average and differences along the horizontal direction.

Average_horiz = ( A(:,1:2:size(A,1)) + A(:,2:2:size(A,1)) )/sqrt(2);
Differences_horiz = ( A(:,1:2:size(A,1)) - A(:,2:2:size(A,1)) )/sqrt(2);

% Concatenate them in the horizontal direction to get the result.

A = cat3(2, Average_horiz, Differences_horiz );

% Assign the transformed data.

MW(1:2^(j+1),1:2^(j+1)) = A;

% Display the result of the horizontal transform.

clf;
imageplot(M,'Original image',1,2,1);
subplot(1,2,2);
plot_wavelet(MW,log2(n)-1);
title('Transformed');




Here is photo_grey.jpg that I want to display: (in figure2)

http://img13.imageshack.us/img13/7281/photogrey.jpg (the file is called photo_grey)

And I have that error on my previous message .
From: Wayne King on
"Sprinceana " <mihaispr(a)yahoo.com> wrote in message <hrrrds$qns$1(a)fred.mathworks.com>...
> Thanks wayne!
>
> The weird thing is that even if I have load_image.m function it gives me this error:
>
> ??? Undefined function or method 'load_image' for input arguments of type 'char'.
>
> n = 256; % size of the image
> M = load_image('photo_grey', n);
> clf;
> imageplot(M);
>
> And it should display my grayscale image. I don't know in fact the source of this error.

Are you sure that the function is somewhere in the MATLAB path?
From: Sprinceana on
Yes it was in the path but I put it otherwise because it appeared me this error:


??? Undefined function or method 'image_resize' for input arguments of type 'double'.

Error in ==> load_image at 86
y = image_resize(y,n,n);


This error is on line 86 of load_image.m

I thought if I put the document in other part I solve this error but it gave me that error that I told you.

So the load_image is somewhere bug because it gives me the error on the line 86.

>>haar_transf
??? Undefined function or method 'image_resize' for input arguments of type 'double'.

Error in ==> load_image at 86
y = image_resize(y,n,n);

First error is in load_image.m second error is in haar_trans.m; Sry for disturbing you but I need to do this I'm very close to achieve haar 2d transform.

Error in ==> haar_transf at 20
M = load_image('photo_grey', n);

this is on line 20 on haar_trans.m
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: battery controller
Next: help with unique function