heliosdrm / GRUtils.jl

Tools for using the GR framework in Julia
Other
31 stars 6 forks source link

No Figure Windows on Windows #123

Closed RoyiAvital closed 1 year ago

RoyiAvital commented 1 year ago

I am trying to show an image using GR.jl / GRUtils.jl.

I can show something like that:

using GR;
mI = rand(512, 512);
imshow(mI, colormap = 2); #<! Grayscale colormap

I have a QT based figure open and the image is displayed. Yet if mI = rand(512, 512, 3);, namely RGB image, the above will fail.

So I tried GRUtils.jl, yet then no figure window is opened. Things are stuck for 2-3 seconds and then nothing, no window:

using GRUtils;
mI = rand(512, 512);
imshow(mI); #<! Nothing happens!
heliosdrm commented 1 year ago

I can't reproduce that with GRUtils. Are you perhaps using GR and GRUtils in the same session? If that's the case, imshow is ambiguous, and you should call either GR.imshow or GRUtils.imshow to disambiguate which function are you trying to use.

RoyiAvital commented 1 year ago

It might be that when it happened both were loaded. I will check again on a lean environment and report.

Thank You.

RoyiAvital commented 1 year ago

By the way, any way to achieve something like https://discourse.julialang.org/t/how-customizable-is-makie/101185/4 with GR.jl or GRUtils.jl?

heliosdrm commented 1 year ago

I don't understand what are you exactly looking for...

RoyiAvital commented 1 year ago

Like Makie / MATLAB, being able to draw an image in 1:1 manner on an axis. Say I have image of 400x400 I want to draw it on axis of size 400x400 so each pixel on the screen will match exactly the element in the image.

heliosdrm commented 1 year ago

You may control the aspect ratio in GRUtils with aspectratio

RoyiAvital commented 1 year ago

I am not talking about the aspect ration.

I am talking about the size of the axis. In the example above, I want the axis displayed on the screen to have the exact size of 400x400.

heliosdrm commented 1 year ago

The size of the figure can be set with the Figure constructor. But that also includes the margins etc.

The proportions and sizes of the elements in the figure can be controlled too (see specially the Viewport), however that requires some lower-level manipulation, and there is no quick recipe implemented so far.

RoyiAvital commented 1 year ago

I see. I read all documentation and didn't figure it out. So I guess it is not available yet. It would be great for an option, specifically for images, to have 1:1 mode where each pixel on the display is exactly one element in the matrix.

Should I open an issue for this feature request? It is the main missing feature in my daily work with GR.jl.

heliosdrm commented 1 year ago

Of course, you can open a specific issue to request that feature (and close this one, if the original issue is actually resolved), but please note that:

RoyiAvital commented 1 year ago

The problem with imshow() is it requires image data type as defined in the Julia Images eco system. It doesn't give a solution for regular arrays. So it is not a valid solution in many cases.

GR.jl / GRUtils.jl are very fast and compact. Hence I'd be happy to use them. I don't use Julia for work (Usually MATLAB and Python), only as an hobby.

I started with GR.jl, yet its documentation is sparse so I switches to GRUtils.jl.