X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 26 Jan 2021 06:01 AM by  Judy Northrop
IDL 8.8 Python image display
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Judy Northrop



New Member


Posts:1
New Member


--
24 Jan 2021 06:33 PM
    I want to use Python's imshow routine to plot the spectral response of hyperspectral images, but I cannot get a simple 2D image to display. One dimensional plots work fine using matplotlib. I am using IDL 8.8 with the following,

    IDL> plt = Python.Import('matplotlib.pyplot')
    % Loaded DLM: PYTHON37.

    IDL> help, im60
    IM60 FLOAT = Array[584, 1000]

    IDL> plt.imshow(im60)
    Fatal error: IDL has encountered a fatal error and will now exit

    I am using Linux x64 with Anaconda3 2020, Python 3.7


    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    25 Jan 2021 09:54 AM
    Does imshow() work fine if run normally from just Python?
    Have you tried using the IDL-Python bridge from Command Line and IDLDE?

    Does IDL still crash with this example code below?

    plt = Python.Import('matplotlib.pyplot')
    Python.plt = plt
    p = plot(/test)
    image = reverse(p.copywindow(),3)
    !null = plt.title('IDL Graphic Embedded in Python')
    !null = plt.axis('off')
    !null = plt.imshow(image)javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("dnn$ctr10412$ActiveForums$ctl00$topic$ctl06$btnSubmitLink", "", true, "", "", false, true))
    !null = plt.show()

    Judy Northrop



    New Member


    Posts:1
    New Member


    --
    26 Jan 2021 06:01 AM
    Hello, thank you for the help!

    Yes imshow() work when running in Python(), I actually need the imshow() provided in the spectral library, the usage is

    from spectral import *
    view = imshow(hsi_image, bands=(58, 38, 18))

    I did run the provided example from both the command line and within idlde. I could not run the line with the imshow line with the web output, there is an error, but I was able to run this code


    IDL> plt = Python.Import('matplotlib.pyplot')
    % Loaded DLM: PYTHON37.
    IDL> Python.plt = plt
    IDL> p = plot(/test)
    % Loaded DLM: PNG.
    Warning: Cannot convert string "-adobe-helvetica-medium-r-normal-*-*-120-75-75-p-*-iso8859-1" to type FontStruct
    % Loaded DLM: LAPACK.
    IDL> image = reverse(p.copywindow(),3)
    IDL> !null = plt.title('IDL Graphic Embedded in Python')
    IDL> !null = plt.axis('off')
    IDL> !null = plt.imshow(image)
    IDL> !null = plt.show()

    This seems to work but is a little buggy in that if I do not immediately follow !null = plt.imshow(image) with !null = plt.show() idl Segmentation faults or if I close the window launched with p = plot(/test) idl Segmentation faults.
    IDL> Segmentation fault (core dumped)


    With the p = plot(/test) window open, I was able to display an RGB with,
    IDL> !null = plt.imshow(RGB)
    IDL> !null = plt.show()

    Same behavior in from the command line and withing the idle.

    Thanks again,
    Judy

    You are not authorized to post a reply.