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

imshow in Julia is now broken because of the pad #8254

Closed
joa-quim opened this issue Jan 2, 2024 · 12 comments · Fixed by #8255
Closed

imshow in Julia is now broken because of the pad #8254

joa-quim opened this issue Jan 2, 2024 · 12 comments · Fixed by #8255
Labels
bug Something isn't working

Comments

@joa-quim
Copy link
Member

joa-quim commented Jan 2, 2024

Plot is linear. Should not need any PAD.

julia> gmtwrite("lixo1.tif", rand(UInt8,32,32,3), driver=:GTiff)

julia> I = gmtread("lixo1.tif", img=true, band=[0 1 2]);

julia> imshow(I)
GMT [WARNING]: gmtapi_change_imagelayout: reordering function for case BRBa -> BRP not yet written. Doing nothing.
grdimage [ERROR]: gmt_img_project: Input image does not have sufficient (2) padding
ERROR: Something went wrong when calling the module. GMT error number = 79
@joa-quim joa-quim added the bug Something isn't working label Jan 2, 2024
@joa-quim
Copy link
Member Author

joa-quim commented Jan 2, 2024

Case is deeper. 2 bands???

julia> I = gmtread("lixo1.tif", band=[0 1 2])
A GMTimage object with 2 bands of type UInt8
julia> I = gmtread("lixo.tif")
A GMTimage object with 3 bands of type UInt8

This case plots fine

OK, the 2 bands is an older issue and probably because somewhere I changed to count-bands-from-one in GMT.jl, but that is what actually triggered the issue. A git bisect shows that it was something in "Final version of updates for 6.5: grdimage, colorbar, grdmix (#8251)"

@PaulWessel
Copy link
Member

Please attach lixo1.tif so I can see. Is it grayscale with transparency?

@joa-quim
Copy link
Member Author

joa-quim commented Jan 2, 2024

To get the file is just run the gmtwrite command that I posted.

@joa-quim joa-quim mentioned this issue Jan 2, 2024
53 tasks
@joa-quim
Copy link
Member Author

joa-quim commented Jan 2, 2024

The file doesn't really matters. It's the fact that when imported when only 2 bands triggers the bug. And it should also not try to change the layout.

lixo.tif.zip

@PaulWessel
Copy link
Member

I dont understand. gdalinfo says it has 3 bands, you say 2. If I plot what you sent (wasn't lixo1 though?) and I grdimage limo.tif -B -png t it looks exactly like the input (but 15c of course). Can you show me exactly what goes wrong and where your pad issue enters?

@PaulWessel
Copy link
Member

Give me a CLI grdimage command that crashes and I can debug.

@joa-quim
Copy link
Member Author

joa-quim commented Jan 2, 2024

You have to read the Julia messages.

julia> gmtwrite("lixo.tif", rand(UInt8,32,32,3), driver=:GTiff)

julia> I = gmtread("lixo.tif", img=true, band=[0 1 2])
A GMTimage object with 2 bands of type UInt8
Pixel node registration used
x_min: 0.5      x_max :32.5     x_inc :1.0      n_columns :32
y_min: 0.5      y_max :32.5     y_inc :1.0      n_rows :32
z_min: 0.0      z_max :255.0
Mem layout:     BRBa

Above the printing clearly says the image has only 2 bands.

julia> imshow(I)
GMT [WARNING]: gmtapi_change_imagelayout: reordering function for case BRBa -> BRP not yet written. Doing nothing.
grdimage [ERROR]: gmt_img_project: Input image does not have sufficient (2) padding
ERROR: Something went wrong when calling the module. GMT error number = 79

Tried to save that 2 bands image again, but some other shit gets in the middle.

julia> gmtwrite("lixo_2b.tiff", I,  driver=:GTiff)
GMT [WARNING]: gmtapi_change_imagelayout: reordering function for case BRBa -> BRP not yet written. Doing nothing.
gmtwrite [ERROR]: BRBa memory layout is not supported, for now only: T(op)C(ol)B(and) or TRP & BRP
gmtwrite (gmt_api.c:5147(gmtapi_export_image)): Unknown Error [lixo_2b.tiff]
[Session GMT (2)]: Error returned from GMT API: GMT_IMAGE_WRITE_ERROR (23)
[Session GMT (2)]: Error returned from GMT API: GMT_IMAGE_WRITE_ERROR (23)
[Session GMT (2)]: Error returned from GMT API: GMT_IMAGE_WRITE_ERROR (23)
ERROR: Something went wrong when calling the module. GMT error number = 23

@PaulWessel
Copy link
Member

But I am not using Julia and just want a file from you that when read into GMT causes troubles. Is the problem only when using gmtread/gmtwrite and not when doing things in a module?

@PaulWessel
Copy link
Member

I mean, if gmtread/write insisted on there being pads then that is not right since there is no projection there?

@joa-quim
Copy link
Member Author

joa-quim commented Jan 2, 2024

I don't have one 2 bands file. I tried to create one above but it errored too. The problem is that grdimage is sending the image through the if (Ctrl->D.active) { /* Must project the input image instead */ branch that calls
if (gmt_img_project (GMT, I, Img_proj, false)) Return (GMT_RUNTIME_ERROR); /* Now project the image onto the projected rectangle */
and that requires a pad. But why projecting if the generated command was

grdimage  -JX15c/0 -n+a -R0.5/32.5/0.5/32.5 -D -P -K > c:\\TMP/GMTjl_j.ps

@PaulWessel
Copy link
Member

OK, agree that projection makes no sense. Will look after dinner (like you tell me so often!)

@joa-quim
Copy link
Member Author

joa-quim commented Jan 2, 2024

It's this GOTO
image

(like you tell me so often!)

But never by this solar altitude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants