IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 21 years ago

Closed 21 years ago

Last modified 21 years ago

#307 closed defect (fixed)

psImagePowerSpectrum returns NaN image

Reported by: Paul Price Owned by: robert.desonia@…
Priority: high Milestone:
Component: imageops Version: 0.4.0
Severity: normal Keywords:
Cc:

Description

Calling psImagePowerSpectrum on a 256x256 image results in an output image
composed of NaNs. This is because numElementsSquared goes as the number of
elements to the fourth power, which clocks a psS32 for a 256x256 image
(numElementsSquared = 0). Since OTA cells are 512x512, this range is not
sufficient.

The function works adequately when numCols, numRows and numElementsSquared are
all changed to psU64 types. This would give us the capability of handling
square images up to 64k pixels on each axis. This should be sufficient for our
needs, but a check for this should be added to the function.

I can't dream up a workaround.

Attachments (1)

testFFT.c (3.6 KB ) - added by Paul Price 21 years ago.
testFFT.c

Download all attachments as: .zip

Change History (8)

comment:1 by robert.desonia@…, 21 years ago

Status: newassigned

comment:2 by robert.desonia@…, 21 years ago

Resolution: fixed
Status: assignedclosed

I didn't take your suggestion, as when I looked at where it was used, it was
better to be either a psF32 or psF64, depending on the input data type. This
avoids a integer->floating-point cast within a inner loop through the pixels,
potentially increasing performance.

Since floating-point is used, there is no practical limit in image size to
check, so no overflow check was added either.

comment:3 by Paul Price, 21 years ago

Even better!

comment:4 by Paul Price, 21 years ago

Resolution: fixed
Status: closedreopened

The problem has not been fixed. I will attach code to reproduce.

by Paul Price, 21 years ago

Attachment: testFFT.c added

testFFT.c

comment:5 by Paul Price, 21 years ago

I expect the fault still lies with the line:

psF32 numElementsSquared = numCols * numCols * numRows * numRows;

I suspect integer math is being performed, the result of which is then converted
to float, but the damage is already done.

The following fix works:

psF32 numElementsSquared = numCols * numRows;
numElementsSquared *= numElementsSquared;

comment:6 by robert.desonia@…, 21 years ago

Resolution: fixed
Status: reopenedclosed

OK, I changed the line you highlighted to:

psF32 fNumCols = numCols;
psF32 fNumRows = numRows;
psF32 numElementsSquared = fNumCols * fNumCols * fNumRows * fNumRows;


That should not have any integer overflow problems as no integer math is
committed.

comment:7 by Paul Price, 21 years ago

Verified.

Perhaps the code I provided could be used in the regression tests.

Note: See TracTickets for help on using tickets.