From: Steven Lord on

"Shamane " <tan.shamane(a)gmail.com> wrote in message
news:hllle2$p81$1(a)fred.mathworks.com...
> Steve Eddins <Steve.Eddins(a)mathworks.com> wrote in message
> <hlk4j7$2an$1(a)fred.mathworks.com>...
>> Shamane wrote:
>> > Hi everyone, this is so urgent because I'm rushing for a deadline and I
>> > can't seem to solve it! :( Here's the background: Initially, I have an
>> > image X in Lab type which can be converted successfully from Lab to
>> > srgb using:
>> > srgb_image = applycform(X, makecform('lab2srgb'));
>> >
>> > However, I realised that the pixels in my Lab image were diagonally
>> > switched, which was the root cause of why my image colors were flipped
>> > diagonally. Hence, after making ammendments to my error and swapping my
>> > x and y coordinates, I tried to convert from Lab to srgb but this time
>> > to no avail. Here are the errors:
>> >
>> > ??? Error using ==> iptcheckinput
>> > Function APPLYCFORM expected its first input, IN, to be finite.
>> >
>> > Error in ==> applycform>check_inputs at 108
>> > iptcheckinput(in,{'double','uint8','uint16'},{'real','nonsparse','finite'},...
>> > Error in ==> applycform at 58
>> > check_inputs(in);
>> >
>> > Error in ==> test at 139
>> > srgb_image = applycform(X, makecform('lab2srgb'));
>> >
>> > How come now my image X is not detected as finite by the function
>> > APPLYCFORM? Will really appreciate your help.
>>
>> Well, my initial guess is that some element of X is not finite. ;-)
>>
>> What do you get when you do this:
>>
>> any(~isfinite(X(:)))
>>
>> ---
>> Steve Eddins
>> http://blogs.mathworks.com/steve/
>
> I tried, the answer is 1... so that means it's finite right?

Other way around.

AreAllPointsFinite = all(isfinite(X(:))

returns false, so you have at least one nonfinite value in X. To find it or
them:

linearIndex = find(~isfinite(X(:)))
yLinear = X(linearIndex)
% or
[rowIndex, columnIndex] = find(~isfinite(X));
ySubscript = X(rowIndex, columnIndex)

The elements of yLinear or the diagonals of ySubscript should be Inf, -Inf,
or NaN. Given that information, you'll need to work your way back through
your code looking for where those nonfinite values were introduced. Setting
an error breakpoint may help you in your debugging.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/brqxeeu-175.html#brqxeeu-242

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ