How to convert jpeg zero point (0,0) from UL to LL?

Added by John 2 months ago

Aloha.

I'm trying to figure out if there is an obvious way to take a jpeg image with (0,0) in the UL and change it to LL without doing it 'the hard way'. When I load them with grdimage, it seems to reset the (0,0) such that xmin=0, ymin=0 but when I then use 'convert' on the *.ps output to get a new jpeg image with LL as the zero, I'm back to the old UL zero point (or so it seems when I load it in GIMP).

Any advice on this is much appreciated.
J.


Replies (3)

RE: How to convert jpeg zero point (0,0) from UL to LL? - Added by Joaquim 2 months ago

Though I hate origins at UL (there was a guy at school called Descartes who taught us that all origins are at LL), I don't remember to have taken any particular measure to UpDown flip images. Is it what is this about? Because I'm not sure I understood the issue.

RE: How to convert jpeg zero point (0,0) from UL to LL? - Added by John 2 months ago

Mahalo, JL.

It's an issue because I'm working on a pilot study for co-registering medical images from different instruments and I need to digitize control points in GIMP (or similar). Those need to be corrected to LL (0,0) to minimize confusion in downstream processing. If successful, we'll need to scale this up to millions (maybe billions) of images.

For example, grdinfo reports (via GDAL):

vpn-sdsc-137-110-10-80.ucsd.edu:~/Projects-200/Project-Zhang/data/level0/AMD-Test-001>grdinfo NORMAL.jpeg
NORMAL.jpeg: Title: Grid imported via GDAL
NORMAL.jpeg: Command:
NORMAL.jpeg: Remark:
NORMAL.jpeg: Pixel node registration used [Cartesian grid]
NORMAL.jpeg: Grid file format: gd = Import/export through GDAL
NORMAL.jpeg: x_min: 0 x_max: 1572 x_inc: 1 name: n_columns: 1572
NORMAL.jpeg: y_min: 0 y_max: 1308 y_inc: 1 name: n_rows: 1308
NORMAL.jpeg: z_min: 0 z_max: 255 name: z
NORMAL.jpeg: scale_factor: 1 add_offset: 0

I'd like to avoid that step if there is something in gdal or ImageMagick (or GIMP) with an option to convert UL to LL. I can't find anything and see that there is a long history of people wanting to do this sort of thing in Googleland. Maybe there's something to be done with 'add_offset', for example. I'll jury-rig it with awk in the meantime.

RE: How to convert jpeg zero point (0,0) from UL to LL? - Added by Joaquim 2 months ago

Sorry, still don't get it all. A jpeg image has no axes so it's just a matter of how the data array is stored. If you wan to change the origin, isn't it a question of updown flipping the image?
We do have the notion of images memory layout, but that is only currently explored by the Matlab and Julia interfaces.

(1-3/3)