# Is imadjust a Matlab-only library? If so, can it be replaced?

I want to apply a homomorphic process to an image, and one of the steps involves the imadjust function. The source of this code is http://www.csse.uwa.edu.au/~pk/research/matlabfns/

One of the steps in the homomorphic process is the histogram truncation. This is where toward the end, imadjust is applied like this

newim = imadjust(im,gv,[0 1]);


Unfortunately Octave doesn't seem to have this function, so I'm guessing it's a Matlab Image Processing Toolkit function. Is there a way to replace it? I haven't managed to find one that uses just two arguments, in addition to the image.

I found this imadjust.m but it has 4 arguments (image, in, out, and gamma) Not sure how it's related to the one I'm using which is 3 arguments (image, gamma?/interpolated value, and two values array).

The imadjust in Matlab includes 4 arguments as well. You always need to specify the shape of the curve (gamma), and map the values in I to new values in J such that values between low_in and high_in map to values between low_out and high_out.

You can try the link you found yourself, or try this version.

Octave does have this function. You didn't provide the error that lead you to conclude it does not, but here are some guesses:

error: 'imadjust' is undefined near column x line y


This could be because you don't have the image package installed, or maybe you just have not loaded it. I'm using the MacPorts package manager where you can install the package by searching 'octave-image'. If you know you have it installed, make sure it's loaded:

pkg load image


You could also have encountered the problem that octave's implementation does not deal well with different data formats. This problem manifests as the image appearing completely white or black after running through imadjust. If this is the case, then explicitly convert the data to double before handing it to imadjust and explicitly return it to your format after. Example:

my_output = uint8(imadjust(double(my_input),gv,[0;255]));


Finally make sure that your gv is a 2 element vector.