Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the duplication and freeing of GMT_IMAGE #3438

Merged
merged 9 commits into from
Jun 8, 2020

Conversation

PaulWessel
Copy link
Member

@PaulWessel PaulWessel commented Jun 7, 2020

Two main problems fixed, but the plotting is still not correct:

  1. GMT_IMAGE members colormap and color_interp were not duplicated by GMT_Duplicate_Data.
  2. grdimage projected I to Img_proj and deleted I, but then refered to I->colormap instead of Img_proj->colormap.

However, the colormap entries we do obtain in gmt_gdalread.c do not match the ones gdalinfo reports on the command-line and the image looks like shit. See #3436 for more information.

Several problems fixed, but not completed:
1. GMT_IMAGE members colormap and color_interp were not duplicated by GMT_Duplicate_Data.
2. grdimage projected I to Img_proj and deleted I, but then refered to I->colormap instead of Img_proj->colormap

However, the colormap entries we obtain do not match the ones gdalinfo reports on the commandline and the image looks like shit.
Fix registration issues in marbles and update orig, add GMT_IMAGE_NO_INDEX mode flag to ensure the returned image is not indexed but expanded to colors.  This is needed in the plotters like grdimage, grdview and grdmix due to projection or blending.
@PaulWessel PaulWessel changed the title WIP Fix the duplication and freeing of GMT_IMAGE Fix the duplication and freeing of GMT_IMAGE Jun 8, 2020
@PaulWessel
Copy link
Member Author

I think this is now all working (at least for me on macOS locally). Need to be tested on other OS as well. Here are the changes:

  1. Added new mode bit-flag GMT_IMAGE_NO_INDEX which can be passed into GMT_Read_Data when images are read. If set and the image is an indexed image, then we expand to rgb using the currently selected memory layout. This is needed because different modules work with different default layouts: grimage wants RGB[A]RGB[A]RGB... while grdmix expects RRRR...GGGG.BBBB.
  2. Updated a few scripts and orig PS. The images we use are slightly different from the original marbles, so the PS must change. Also, some scripts did a forced registration changed that no longer is needed.
  3. Implements the corrections needed in GMT_Duplicate_Data for images that we discussed yesterday.

This PR closes #3436.

@PaulWessel
Copy link
Member Author

I know @joa-quim said he may be off this evening but we probably want to wait to merge until he gets a test in. Hopefully @seisman can give it a spin in the CI.

@joa-quim
Copy link
Member

joa-quim commented Jun 8, 2020

It works but prints that annoying and false warning 3 three times and mixes ERROR and WARNING

gmt grdimage -JG0/0/3i @earth_day_01d -B -pdf map
grdimage [NOTICE]: Remote data courtesy of GMT data server OCEANIA [https://oceania.generic-mapping-tools.org]

grdimage [NOTICE]: Earth Daytime Image at 1x1 arc degrees [NASA image mosaic - Blue Marble].
grdimage [NOTICE]:   -> Download grid file [44K]: earth_day_01d_p.tif
grdimage [ERROR]: Illegal code [grdimage [ERROR]: Illegal code [grdimage [ERROR]: Illegal code [grdimage [WARNING]: The image memory layout (TRP ) is of a wrong type. It should be BRPa.

@PaulWessel
Copy link
Member Author

But I deal with that.... OK will check.

@PaulWessel
Copy link
Member Author

Try now.

Copy link
Member

@joa-quim joa-quim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works now and silently

Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests ex52 and marbles.sh pass on all platforms.

@PaulWessel PaulWessel merged commit 98768af into master Jun 8, 2020
@PaulWessel PaulWessel deleted the image-duplication-freeing branch June 8, 2020 01:52
@PaulWessel
Copy link
Member Author

I think grdimage.c can loose some lines. If I am correct, @joa-quim, given that indexed images ahve been replaced earlier, we only either have gray or RGB[A] images in the loops, and we only need to copy the R[GB] into the rgb array for 1 or 3 values. So the business with r_table, g_table, b_table is no longer needed I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants