0
votes

I using the following code in matlab to attempt to apply haar dwt to bitmap image

im = imread('image.bmp');
[LL,LH,HL,HH] = dwt2(im,'haar');  
 figure; imshow(im);

I am getting the following error: Undefined function 'dwt2' for input arguments of type 'uint8' I have just downloaded the wavelet toolbox. I thought dwt accepted uint8 type??

1
Check the toolbox is properly installed and the function is on your path (which dwt2 from command line should show it).nkjt
I'm sorry could you be more specific??user1877082
Type which dwt2 into your commandline. If the toolbox is properly installed, it should return the location of the file. If it doesn't, you need to change your path to include the location of the toolbox, because MATLAB doesn't search your entire harddrive to find a function.nkjt
thank you! it is not recognising it. How do I change the path??user1877082
@user1877082 addpath('folder_where_you_have_the_toolbox_instaled').Ander Biguri

1 Answers

0
votes

"Undefined function" errors are commonly not because of the wrong type of input argument, but because MATLAB can't find the file. To call a function it should be:

  1. In an *.m file with the same name as the function (e.g. myfunc.m for function myfunc)
  2. In the current working folder or on the MATLAB path, which tells MATLAB where to look for files.

Normally when installing a MATLAB toolbox it will automatically be added to the path, but third-party toolboxes often need to be manually added. Make sure you add all subdirectories as well. You can do this using genpath in addition to addpath:

addpath(genpath('c:/matlab/mytoolbox'))

There is also a graphical interface for changing the MATLAB path, accessible from the commandline by typing pathtool. Again, for a toolbox, use "Add with Subfolders".