With some experimentation, it was determined that when the QPainterPath
is drawn with a QPen that has a thickness greater than 1, the end result
is quite broken. Due to us trying to exploit non-advertised behavior
we are removing this optimization step.
* Update GLViewWidget.py
Fix the wrong conversion of QVector3D to numpy array.
* new way to fix the conversion error
* Recover prev. version of pixelSize
Co-authored-by: Jaeyoon Jeong <diem389@gmail.com>
Several bugs have snuck through due to being wrapped with printExc,
which would prevent the exception from raising, but printing the trace
to the console. In pytest, this output is not captured at all, and is
invisible unless the -s parameter is added.
This PR changes the print statement to a runtime warning, which pytest
will capture.
To reduce complexity, and make it easier to add more images and tests,
the images in the `test-data` repository should be merged with the main
repository. Furthermore, we can remove a lot of the subprocess work in
the image_testing.py file, as we no longer need to have it interact with
git.
The images are not the same. Images were regenerated with Qt6, and now
have proper big and little endian handling thanks to @pijyoi
Second commit is a slightly modified variant of
2e135ab282d6007b34a3854921be54d0e9efb241 authored by @pijyoi
it is to convert qimages to RGBA8888 for testing. Image
files were regenerated images for the big/little handling
Fixed issue with bogus test from test_NonUniformImage and generated a
new image
Since the QPainterPath.addPolygon(QPolygonF) does not filter out the NaN
values, we can insert NaN values to create discontinuities in the Lines,
and thus supporting connect='pairs' functionality
As discussed earlier, the process of QDataStream >> QPainterPath is
quite slow, so this commit makes an improvement on QPainterPath creation
for the case of connect='pairs' by using a naive method of moving the
path and drawing a line on the path. This was the fastest method
identified during testing.
The check for NaN values in arrayToQPath is expensive, this change
attempts to do the check one time, and if no NaN values are present,
an optional flag is passed along telling arrayToQPath that the check
can be skipped
Since QDataStream >> QPainterPath is an expensive operation, we can
construct our QPainterPath from an open polygon instead but only if the
connect='all' mode is present. Future optimizations work can likely
be had with constructing a polygon from each connected segment
* refactor out _ndarray_to_qimage()
* combine levels back with lut
* make use of Grayscale8, RGB888 and Indexed8 QImage formats
Grayscale8 and RGB888 images are those that are ready for display
without further processing.
* add Grayscale16
* apply the efflut early for uint16 mono/rgb, uint8 rgb
* ndarray indexing is faster than np.take
* handle uint16 rgb(a) with no levels same as levels=[0, 65535]
* add support for Format_RGBA64
* fix: support colormaps of shape (h, 1)
* check ImageItem uint8 and uint16 QImage formats
* uint16 mono with rgb lut -> RGBX8888
* got width and height swapped in array dimensions
* set ImageItem as row-major
* no need to form a 1d 32-bit lut for array indexing
you can index (y, x) into a lookup table of shape (nentry, 3) or
(nentry, 4) and get an output of shape (y, x, 3) or (y, x, 4)
* Revert "no need to form a 1d 32-bit lut for array indexing"
This reverts commit 45cf3100de.
* distinguish between levels_lut and colors_lut
this allows uint16 images with user lut to be rendered as
Format_Indexed8
* uint8 (1-chan) images should always combine to efflut
this efflut will then be used for Indexed8 format color table.
previously, we would be taking a performance hit with doing a numpy
lookup with levels_lut.
* adapt benchmarks/makeARGB.py to renderImageItem.py
* restructure uint8 and uint16 codepaths
* normalize 1-chan images to ndim==2 earlier up
* refactor long code into functions
* bug: qimage may not be assigned
* fix: assign to self.qimage only if not None
* for uint16, do rescale rather than do levels_lut lookup
* cases 2,3 are already handled
i.e. no more using lut to do rescale of uint16 image data.
* rescale rgb images by computation, not by memory lookup
* setImage() does not take an output argument
* try to be cupy compatible
use "xp" instead of numpy module
* add numba to benchmarking
* fix: lut_big is dtype uint8 with more than 256 entries
* bug: applying colors_lut needs C-order
* support float with no nans
* fix: variable could be uninitialized
* add float32 format tests
* avoid explicitly forcing to C-contiguous
* cache effective lut only if combination took place
every one of the four branches now does its own return.
this makes it easier to follow.
* fix cupy benchmark : typo in renderQImage
* remove for loop of 1 iteration
* use float32 for floating point benchmark
* superceded by renderImageItem.py
* lint
* benchmark without lut conversion
* put the lut onto the substrate
* fix editor complaints
* handle lack of cupy
* leading underscores imply privacy
Co-authored-by: KIU Shueng Chuan <nixchuan@gmail.com>
this also fixes the assumption that we are on little-endian.
In [18]: qimg = QtGui.QImage(1, 1, QtGui.QImage.Format.Format_RGB32)
In [19]: qimg.fill(QtCore.Qt.GlobalColor.transparent)
In [20]: np.frombuffer(qimg.bits(), dtype=np.uint8)
Out[20]: array([ 0, 0, 0, 255], dtype=uint8)
* added convenience functions to better handle plotting with gradients
* docstring correction, example name correction
* retrying to get documentation format right
* another attempt at cleaning up docs
* Don't hardcode timer type (and docs fixing attempt)
* more docstring re-formatting
* linebreaks in docstrings
* more documentation adjustments
* documentation pass
* some corrections to documentation
* more adjustments to documentation
* again?
* removed some whitespace and redundant blank lines, changed some checks '== None' to 'is None'
* fixed mis-spelling QColor as Qcolor