Thanks, Kenny! That indeed is the same problem. The mx+= 1 fix you
implemented looks fine to me. Thanks for the help.
Erik

On Sat, Nov 23, 2019 at 5:23 PM Kenneth Lyons <[email protected]> wrote:

> Hi Erik, I believe this is the same issue reported here:
> https://github.com/pyqtgraph/pyqtgraph/issues/1033
>
> The comments there are still accurate (fixed version not released yet),
> but there are instructions for installing pyqtgraph via git.
>
> Hope that helps.
>
> - Kenny
>
> On Saturday, November 23, 2019 at 2:29:56 PM UTC-8, Erik J wrote:
>>
>>
>>
>> On Saturday, November 23, 2019 at 3:27:05 PM UTC-7, Erik J wrote:
>>>
>>> Hi everyone,
>>>
>>> I am using a HistogramLutWidget for an image that is displayed in a
>>> pg.GraphicsLayoutWidget. The image is a dark and gain corrected image from
>>> a CCD camera that updates in real time as it is received from the camera.
>>> The problem I am having is that the ImageItem in the histogram display will
>>> crash periodically in the method getHistogram(). This occurs if the min and
>>> max of the image are the same. Here is the code snippet from getHistogram:
>>>
>>>         if bins == 'auto':
>>>             if stepData.dtype.kind in "ui":
>>>                 mn = stepData.min()
>>>                 mx = stepData.max()
>>>                 step = np.ceil((mx-mn) / 500.)
>>>                 bins = np.arange(mn, mx+1.01*step, step, dtype=np.int)
>>>                 if len(bins) == 0:
>>>                     bins = [mn, mx]
>>>             else:
>>>                 bins = 500
>>>
>>> If mn and mx are equal, then np.arange() fails with an error. I suggest
>>> the following code change to fix the problem:
>>>         if bins == 'auto':
>>>             if stepData.dtype.kind in "ui":
>>>                 mn = stepData.min()
>>>                 mx = stepData.max()
>>>                 step = np.ceil((mx-mn) / 500.)
>>>
>>>                 bins = np.arange(mn, mx+1.01*step, step, dtype=np.int)
>>>                 if len(bins) == 0:
>>>                     bins = [mn, mx]
>>>             else:
>>>                 bins = 500
>>>
>>>
>>> Sorry, somehow this got posted before I was finished. The new code
>>> should be:
>>>
>>
>>         if bins == 'auto':
>>             if stepData.dtype.kind in "ui":
>>                 mn = stepData.min()
>>                 mx = stepData.max()
>>                 step = np.ceil((mx-mn) / 500.)
>>                 if step == 0: step = 1.0
>>                 bins = np.arange(mn, mx+1.01*step, step, dtype=np.int)
>>                 if len(bins) == 0:
>>                     bins = [mn, mx]
>>             else:
>>                 bins = 500
>>
>>
>> Please let me know if anyone else has experienced this problem. It can
>> easily occur if an image is saturated or if nearly all the pixels are zero.
>>
>> Thanks,
>> Erik
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "pyqtgraph" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pyqtgraph/d6dfc5ad-8fda-45ab-9531-81f84fa5a89b%40googlegroups.com
> <https://groups.google.com/d/msgid/pyqtgraph/d6dfc5ad-8fda-45ab-9531-81f84fa5a89b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

************************************************
Erik JohanssonProject Manager, Wavefront Correction System
National Solar Observatory
Daniel K Inouye Solar Telescope
3665 Discovery Drive, Boulder, CO 80303
Tel: 303-735-7723
************************************************

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/CAMZ%2Bua%3DG9ei5j_DRa2V6UkMoTOpSqH2vYUbNCYhETjK6U63d5w%40mail.gmail.com.

Reply via email to