Undefined function or variable 'X'

Hi,
I want to make a fusion of two images using this example:
but when i write
load('D:\pix.jpg');X1 = X;
then i receive the message :
Undefined function or variable 'X'.
What can I do to fix it? And what are X1 = X; and X2 = X;,can you explain me, pls?

回答 (1 件)

Thorsten
Thorsten 2015 年 11 月 16 日
編集済み: Thorsten 2015 年 11 月 16 日

2 投票

In the example, a variable X is stored in mask.mat and bust.mat, that are assinged to X1 and X2, resp., after loading. If you don't have these file, the code does not work.
You need to modify it such hat two images are stored in X1 an X2.
To read an image, use
X1 = imread('D:\pix.jpg');

15 件のコメント

Nokia Nokia
Nokia Nokia 2015 年 11 月 16 日
Thanks a lot! :) But now when I continue to write the commands I receive another error message: colormap(map); Undefined function or variable 'map'. What to do now?
Image Analyst
Image Analyst 2015 年 11 月 16 日
You need to assign a map, like
myColorMap = jet(256);
colormap(myColorMap);
Nokia Nokia
Nokia Nokia 2015 年 11 月 16 日
Thank you! :) But another error has occured: subplot(221), image(X1), axis square, title('Mask') subplot(222), image(X2), axis square, title('Bust') subplot(223), image(XFUSmean), axis square, title('Synthesized image, mean-mean') subplot(224), image(XFUSmaxmin), axis square, title('Synthesized image, max-min') Error using image TrueColor CData contains element out of range 0.0 <= value <= 1.0
Now what?
Thorsten
Thorsten 2015 年 11 月 17 日
You should scale your images to the range [0,1].
Nokia Nokia
Nokia Nokia 2015 年 11 月 17 日
How to scale my image to the desired range? What command to use? Do I need to convert it to grayscale?
Thorsten
Thorsten 2015 年 11 月 17 日
I01 = double(I)/double(max(I(:)));
Nokia Nokia
Nokia Nokia 2015 年 11 月 17 日
it's written:
Undefined function or variable 'I'.
Thorsten
Thorsten 2015 年 11 月 17 日
I is the image to be normized. Use your variable.
Nokia Nokia
Nokia Nokia 2015 年 11 月 22 日
編集済み: Walter Roberson 2015 年 11 月 23 日
So I have to put the image and the pathway instead I like,right? :
I01 = double('D:\pix1.jpg')/double(max('D:\pix1.jpg'(:)));
I02 = double('D:\pix2.jpg')/double(max('D:\pix2.jpg'(:)));
Now i see more error messages :(
Can you tell me what to do now in detail?
Thorsten
Thorsten 2015 年 11 月 23 日
編集済み: Thorsten 2015 年 11 月 23 日
To read an image from file, and convert to double in the range [0,1]:
I01 = im2double(imread('D:\pix1.jpg'));
To normalize data
X = X/max(X(:));
Nokia Nokia
Nokia Nokia 2015 年 11 月 23 日
編集済み: Walter Roberson 2015 年 11 月 23 日
I tried this and i tried this too:
clear all
X1 = imread('G:\an1.jpg');
X2 = imread('G:\an2.jpg');
XFUSmean = wfusimg(X1,X2,'db2',1,'mean','mean');
XFUSmaxmin = wfusimg(X1,X2,'db2',1,'max','min');
myColorMap = jet(256);
colormap(myColorMap);
X1 = double(imread('G:\an1.jpg'))/255;
X2 = double(imread('G:\an2.jpg'))/255;
subplot(221), image(X1), axis square, title('Mask')
subplot(222), image(X2), axis square, title('Bust')
subplot(223), image(XFUSmean), axis square,
title('Synthesized image, mean-mean')
subplot(224), image(XFUSmaxmin), axis square,
title('Synthesized image, max-min')
Again an error message:
Error using image
TrueColor CData contains element out of range 0.0 <= value <= 1.0
Walter Roberson
Walter Roberson 2015 年 11 月 23 日
What is max(XFUSmean(:)), min(XFUSmean(:))
Nokia Nokia
Nokia Nokia 2015 年 11 月 23 日
I reduced the images' pixels and now i see the message: Error using wfusimg (line 150) Input images must be of the same size.
Nokia Nokia
Nokia Nokia 2015 年 11 月 23 日
To Walter Roberson
Merge the two images from wavelet decompositions at level 1 using db2 by taking two different fusion methods: fusion by taking the mean for both approximations and details:
XFUSmean = wfusimg(X1,X2,'db2',1,'mean','mean'); and fusion by taking the maximum for approximations and the minimum for the details.
XFUSmaxmin = wfusimg(X1,X2,'db2',1,'max','min');
Nokia Nokia
Nokia Nokia 2015 年 11 月 23 日
now I tried to use the same picture X1 = imread('G:\an1.jpg'); X2 = imread('G:\an1.jpg');
and again: Error using image TrueColor CData contains element out of range 0.0 <= value <= 1.0

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

カテゴリ

質問済み:

2015 年 11 月 16 日

コメント済み:

2015 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by