How do I use imhistmatch in Matlab? - matlab

I'm trying to implement with the matlab function imhistmatch.
So I use following commends.
A= imread('example1.jpg')
B= imread('example2.jpg')
C= imhistmatch(A,B)
But there is problem like this.
?? Undefined functionor method 'imhistmatch' for input arguments of type 'uint8'
So What am I suppose to do for solve?

I am not sure about your question. Are you trying to implement imhistmatch?
Then probably your function is in the wrong folder or you have a typo in the functions name.
use
addpath('Pathto/imhistmatch')
to ensure that matlab can find your implemented function.
But maybe you want to use the function imhistmatch provided by the image processing toolbox. Then, I guess you don't have the image processing toolbox.
Try
ver
and check the output. You should find these lines:
MATLAB Version X.X (XXXXX)
Image Processing Toolbox Version X.X (XXXXX)
If not, then you may want to buy the image processing toolbox, get a evaluation version or maybe try octave.
On my computer the following works:
imhistmatch(ones(10),ones(10))
imhistmatch(ones(10,'uint8'),ones(10,'uint8'))
but when I type
imhistmatch(ones(10,'int8'),ones(10,'int8'))
I get an error:
Error using imhistmatch
Expected input number 1, A, to be one of these types:
uint8, uint16, double, int16, single
Instead its type was int8.
...
So, if it would be a type problem you would see another error.
Your error is the result of not having the proper function imhistmatch.

Related

Using Octave arrayfun with a string argument?

I'm using arrayfun to plot the result of a custom function, which does some logic, look-ups, and calculations. My original call looked similar to this:
plot(x, arrayfun(#Q, x.^2, someNumericVariable));
This worked great. However, in addition to the someNumericVariable parameter, I also wanted to add another parameter, someStringVariable, so I changed it to this:
plot(x, arrayfun(#Q, x.^2, someNumericVariable, someStringVariable));
However, when trying to use this, I get an error:
error: arrayfun: dimensions mismatch
I'm guessing that this happens due to this line in the GNU Octave documentation:
If given more than one array input argument then all input arguments must have the same sizes
(https://www.gnu.org/software/octave/doc/interpreter/Function-Application.html)
So I assume that the string I'm trying to pass is being treated as an array, which has different dimensions than the numeric constant value?
If this is so, are there any workarounds that I can do while keeping the code syntactically concise?
One workaround that would work in MATLAB would be:
plot(x, arrayfun(#(u,v) Q(u,v,someStringVariable), x.^2, someNumericVariable));

Matlab Error: Undefined function 'knnclassify' for input arguments of type 'double'

I am trying to do knnclassify on test_data(10000X784), train_data(50000X784), train_label(50000X1) and k = 1
And I am calling this function as follows:
label = knnclassify(test_data,train_data,train_label,k);
Background:
Where train_label is numeric equivalent digit of the data given in train_data. I want to classify my test_data. The data in both the train and test are in random order, but the train_label totally corresponds with the data in the train_data.
In my friend's workstation it works fine, but in my laptop it gives this error:
Undefined function 'knnclassify' for input arguments of type 'double'.
What could be the reason for the issue and how to solve it? Do I need to install any package? If yes how?
This error means that the function cannot be found in matlab, so you might missing the required toolbox. Just as #schorsch said you need to install the Bioinformatics toolbox.
A way to find out if the function is available in Matlab is typing which knnclassify. The output will be the route where the function resides or 'knnclassify' not found. otherwise.

Matlab - using imquantize()

I found that there is a method called imquantize in order to make a quantization of the input image. I'm trying to make a quantization using 4-bits. I did the following:
>> quan = imquantize(im,16);
But, I got the following error:
??? Undefined function or method 'imquantize' for input arguments of type 'unit8'
How can I go around this?
Thanks.
imquantize is a new function introduced in Image Processing Toolbox R2012b. You can check which image processing toolbox is installed on your matlab (if any) by invoking this command:
ver
imquantize is new to the 2012b release of the Image Processing Toolbox. Therefore, if you don't have 2012b (released last month), you won't have imquantize.
In any case, your usage of imquantize would be incorrect. imquantize takes, as a second argument, a vector of levels to be used as the threshold. Those levels could, for example, be obtained through multithresh (which is also new to IPT 2012b).

bi2de error in MatLab

In MatLab, "> help bi2de" provides the following example:
B = [0 0 1 1; 1 0 1 0];
D = bi2de(B)
But when I try this on my own, I get the following error:
??? Undefined function or method 'bi2de' for input arguments of type 'double'.
Is there something wrong with this function in MatLab?
I am pretty sure that the reason why this problem happened is because of the license of the toolbox, Communications system toolbook, in which this function belongs in. Write which bi2de and see what will be the result. If it returns path of the function and the comment Has no license available, then the problem is related to the license. That means, license of the toolbox is not set correctly. Mostly it happens if the toolbox is added later, i.e., after installation of the original matlab. Please check and solve the license issue, then it will work fine.
bi2de is a function in the Communications toolbox. You need to have that toolbox to use it. If you do have that toolbox, then the problem is that your B matrix is being treated as double instead of binary (I don't have the toolbox so I can't test this).
Consider using bin2dec, which turns a string representation ('1011001', eg) into a decimal number. This function is not part of a toolbox; it's available as part of the basic MATLAB package.

which format can I give to imstack2vectors Matlab function?

So I have imported RGB photo into my Matlab workspace. It says it has value: <200x200x3 uint8>. Meaning it has class uint8. And its name is: prettyPic. So when I try to do the following:
% Convert prettyPic to vector format using function imstack2vectors.
[prettyPic, L] = imstack2vectors(prettyPic);
I get the following error:
??? Undefined function or method 'imstack2vectors' for input
arguments of type 'uint8'.
I was searching google all around reading the Matlab help and even trying to give 'imstack2vectors' different types of variables only to find that none works.
So the question is what type of picture should I feed the 'imstack2vectors' with. And how can I convert the picture that I have to that format/class.
I am a begginer in Matlab so any help would be greatly appreciated!
??? Undefined function or method 'imstack2vectors' for input arguments of type 'uint8'.
Means that most likely, the function imstack2vectors does not exist on your Matlab path (i.e Matlab cannot find a function of this name).
Type which imstack2vectors to see whether Matlab can find it on the path. If it returns nothing, but you know where the function is on your hard drive, you can change directories in Matlab to where the function is located, and then run your command again.
In general, you may want to learn about adding functions to the Matlab path.