GeezerVison is showing github.com — Choose dtype for isolated buffer · Issue #369 · fastplotlib/fastplotlib
Choose dtype for isolated buffer #369DescriptionI just noticed when using uint16 imaging data along with a frame_apply function in ImageWidget: lambda frame: frame - movie_mean, which results in negative values that overflow with numpy uint16 without raising warnings or exceptions. We could either always use float32 as the isolated buffer for ImageGraphic and/or allow choosing the dtype for the isolate buffer. Activitykushalkolar commented on Nov 16, 2023 I propose always casting to float32 for the ImageDataFeature buffer, even simple things like Gaussian filters on uint8 or uint16 images result in overflow and meaningless results.
without casting:

with casting:

I do not think we should expect users to worry about the limitations of the dtype of their raw image data if they are using ImageWidget with frame_apply functions etc. to interactively play with different types of processing 😄 So we should make casting to float32 automatic, unless there are downsides I cannot think of? clewis7 commented on Nov 16, 2023 Sounds good to me...I think float32 gives enough flexibility ArjunPutcha commented on Nov 17, 2023 Agreed. Might still be useful to allow users to pass in dtype if necessary with default float 32. Some image data I acquire with sensor is uint16 or uint8 by default. kushalkolar commented on Nov 17, 2023 I'm not sure how useful it would be to allow users to set the dtype of the
internal buffer. uint isn't useful for any basic image processing. Do you
have an example use case?
…ArjunPutcha commented on Nov 17, 2023 Most image data from sensors I typecast as uint 16 (in firmware) - I'm pretty sure some national instruments tools I use also do the same; generally I want to assess the raw data first to see if analog filtration is going well, not do any digital signal processing, so I'd just read in the data and visualize directly (no need for any additional typecasting). kushalkolar commented on Nov 18, 2023 ah ok, so in this case you would still want to use an isolated buffer but of the same type so it's 1-1 copying into the buffer. ArjunPutcha commented on Nov 18, 2023 Exactly. But I haven't benchmarked how long it takes; I think if you go from uint16 to int32, there's two conversion - uint16 to in16, and int16 to int32. I'd imagine you'd need to do the same to float32, but I'm not sure if the time required to do so is ridiculously long. I can benchmark this coming week.
Also, if I were just visualizing analog data, I'd make a bunch of sensors testing different analog settings and visualize en masse
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|