float image viewer

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

float image viewer

Richard Kirk
Hi.

imshow() is handy because it is always there in Octave. However, there are
things that I need...
- handling of float images
- report of RGB values for pixel at cursor
- dark surround to image

It would be nice to have gamma and range controls. I am happy working with
imshow(I.^0.4) for displaying linear images on a gamma 2.5 monitor, but it
would be nice to get the original floats on a pick, particularly as my
command does nasty things with negative values.

I am currently working on a Mac High Sierra (10.13.3) but I also use CentOS.
I am running Octave 4.2.2.
 
Here's the first exit point. Perhaps we can do all these and I haven't found
them. I think ImageMagic throttles most things to 8- or 16-bits, so we
cannot see anything outside the 0-1 range. That is fair, as we are sending
the image to a display - we ought to be able to get the float pixel values
from the original image data. I am not needing to do critical colour work on
the images, so even 8-bit RGB would probably do; but the black surround is
important.

I do imaging R&D with floating-point images. I made a very raw floating
point format with 4 32-bit integers as header (magic, channels, lines,
pixels) so we can read it with fread, permute, and reshape. I supported this
in my viewer, and it all works. If you draw a rectangle on the cursor, it
can return the image coordinates or the RGB values. Unfortunately, this
viewer is not open source, and is not very lightweight.

Exit point two: if these features are in the pipeline, I can keep my viewer
for now, and wait. I have something that works for now.

I found 'giv' ( http://giv.sourceforge.net/giv/ ) This seems to have support
for 32-bit float image data, custom formats, and lots of overlays. This
might be an open source solution. I haven't managed to build it on the Mac
yet, but I only found it this morning. I don't think using 'xv' helps but I
have hacked 'xv' ages ago, so I might see what it can do.







% FL32 header
H = fread(fid, 4, 'int32');
if H(1) != 842222662
  error('%s is not a float32 image', fname);
end

channels = H(2);
pixels   = H(3);
lines    = H(4);

[A count] = fread(fid, lines*pixels*channels, 'float32');
if count < lines*pixels*channels
  error('%s file truncated', fname);
end

fclose(fid);
dfrm = permute(reshape(A, [lines pixels channels]), [3 2 1]);




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: float image viewer

nrjank
On Fri, Apr 6, 2018 at 11:37 AM, Richard Kirk <[hidden email]> wrote:
Hi.

imshow() is handy because it is always there in Octave. However, there are
things that I need...
- handling of float images
- report of RGB values for pixel at cursor
- dark surround to image

It would be nice to have gamma and range controls. I am happy working with
imshow(I.^0.4) for displaying linear images on a gamma 2.5 monitor, but it
would be nice to get the original floats on a pick, particularly as my
command does nasty things with negative values.

I am currently working on a Mac High Sierra (10.13.3) but I also use CentOS.
I am running Octave 4.2.2.

Here's the first exit point. Perhaps we can do all these and I haven't found
them. I think ImageMagic throttles most things to 8- or 16-bits, so we
cannot see anything outside the 0-1 range. That is fair, as we are sending
the image to a display - we ought to be able to get the float pixel values
from the original image data. I am not needing to do critical colour work on
the images, so even 8-bit RGB would probably do; but the black surround is
important.

I do imaging R&D with floating-point images. I made a very raw floating
point format with 4 32-bit integers as header (magic, channels, lines,
pixels) so we can read it with fread, permute, and reshape. I supported this
in my viewer, and it all works. If you draw a rectangle on the cursor, it
can return the image coordinates or the RGB values. Unfortunately, this
viewer is not open source, and is not very lightweight.

Exit point two: if these features are in the pipeline, I can keep my viewer
for now, and wait. I have something that works for now.

I found 'giv' ( http://giv.sourceforge.net/giv/ ) This seems to have support
for 32-bit float image data, custom formats, and lots of overlays. This
might be an open source solution. I haven't managed to build it on the Mac
yet, but I only found it this morning. I don't think using 'xv' helps but I
have hacked 'xv' ages ago, so I might see what it can do.



compatibility question: are you or anyone else on here familiar with whether Matlab or it's Image toolbox provide any of those functions, and if so how? Are any of these currently not possibly in Matlab that we'd be creating new functionality unbounded by the compatibility concern?  I could run some quick script tests to find out if someone could generate a minimal test.

nickj


Reply | Threaded
Open this post in threaded view
|

Re: float image viewer

Richard Kirk


On 6 Apr 2018, at 19:47, Nicholas Jankowski <[hidden email]> wrote:

compatibility question: are you or anyone else on here familiar with whether Matlab or it's Image toolbox provide any of those functions, and if so how? Are any of these currently not possibly in Matlab that we'd be creating new functionality unbounded by the compatibility concern?  I could run some quick script tests to find out if someone could generate a minimal test.

I do not know whether Matlab supports any of these. I have used Matlab but I do not currently have access to a copy. Clearly, if Matlab has a solution, we should copy that if we can.

My image viewer solution uses standard Octave commands and a few .m files. In that respect, I am not modifying Octave, but providing a library. The modified viewer regularly looked for a file, read a command from that file, executed it, and then deleted it. The Octave commands would generate these command files, and where necessary they blocked until they could read a reply or timeout. The same .m files worked in Matlab (I tried this once to check) so compatibility should not be an issue.

I am not saying the is the only way to go - just that it worked very well for me. I had a viewer that could display floating-point image formats, including video formats, and other motion picture files that are not widely supported; grab the frames, or the part of the frame that was in view; process it in Matlab; then put the image back into the viewer so we could wipe between it and the original.

The ‘gif’ viewer looks like a possible replacement. It is supposed to be cross-platform, but the development is largely on Windows. I have asked whether there is support on the Mac on their forum. I will let this group know if I get a reply.

Thanks.
Richard Kirk



Reply | Threaded
Open this post in threaded view
|

Re: float image viewer

Richard Kirk


On 6 Apr 2018, at 20:53, Richard Kirk <[hidden email]> wrote:

The ‘giv’ viewer looks like a possible replacement. It is supposed to be cross-platform, but the development is largely on Windows. I have asked whether there is support on the Mac on their forum. I will let this group know if I get a reply.

The ‘giv' group is still active. The source is on source forge and https://github.com/dov/giv. No-one has built it on a Mac. I am having a quick go.

Cheers
Richard Kirk



Reply | Threaded
Open this post in threaded view
|

Re: float image viewer

Richard Kirk


On 8 Apr 2018, at 13:39, Richard Kirk <[hidden email]> wrote:

On 6 Apr 2018, at 20:53, Richard Kirk <[hidden email]> wrote:

The ‘giv’ viewer looks like a possible replacement. It is supposed to be cross-platform, but the development is largely on Windows. I have asked whether there is support on the Mac on their forum. I will let this group know if I get a reply.

The ‘giv' group is still active. The source is on source forge and https://github.com/dov/giv. No-one has built it on a Mac. I am having a quick go.

FYI

I have been in contact with Dov Grobgeld, and with his help we have done a build on Macs. The viewer seems nice and fast, but, like gnuplot, defaults to a white surround, but this can probably be fixed. My build is on a branch at GitHub, but the main checkout will probably work soon.

Cheers
Richard Kirk