Ébe Isaac
Ébe Isaac

Reputation: 12341

Octave: How to cirumvent the "imresize: IM must be a grayscale or RGB image" error?

This is an active bug in Octave:

error: imresize: IM must be a grayscale or RGB image.

I can't seem to find a way around this error. Is there any code that is to be added before this statement for it to function as it does in MATLAB?

UPDATE

Code from active bug:

In = ones(6,6);
In(3,3) = 2;
Out = imresize (In, 2);

Version:

Upvotes: 1

Views: 1261

Answers (3)

Ébe Isaac
Ébe Isaac

Reputation: 12341

Exending @Andy's comments, the imresize.m MATLAB file can be placed in the directory of operation. This would execute the code as in MATLAB and would not raise the error like in the Octave's implementation.

The code can be taken from this location.

Upvotes: 0

SergV
SergV

Reputation: 1277

The pixels of grayimage in octave must be in [0..1] range. You can scale amplitude of your matrix to satisfy this criterion:

In = ones(6,6);
In(3,3) = -1;

minIn=min(In(:)); 
maxIn=max(In(:)); 
In1=(In-minIn)/(maxIn - minIn);
Out = imresize (In1, 2);
Out1=Out*(maxIn-minIn) + minIn;

Upvotes: 1

Ander Biguri
Ander Biguri

Reputation: 35525

I havent tested it, but I assume that:

In = ones(6,6);
In(3,3) = -1;

minIn=min(In(:)); % do this
In=In-minIn;      % do this - now In(3,3)=0!

Out = imresize (In, 2);

Out=Out+minIn;    % do this

Will do the job

Upvotes: 0

Related Questions