diff --git a/camviewer_ui_impl.py b/camviewer_ui_impl.py index a854fc0..f600200 100644 --- a/camviewer_ui_impl.py +++ b/camviewer_ui_impl.py @@ -405,6 +405,9 @@ def __init__( self.updateRoiText() self.updateMarkerText(True, True, 0, 15) + self.max_px = 0 + self.min_px = 0 + sizeProjX = QSize(self.viewwidth, self.projsize) self.ui.projH.doResize(sizeProjX) @@ -1378,6 +1381,8 @@ def updateProj(self): projXmax, projYmin, projYmax, + self.max_px, + self.min_px, ) = pycaqtimage.pyUpdateProj( self.imageBuffer, self.ui.checkBoxProjAutoRange.isChecked(), @@ -1385,6 +1390,7 @@ def updateProj(self): self.iRangeMax, self.ui.display_image.rectRoi.oriented(), ) + print(self.min_px, self.max_px) (projXmin, projXmax) = self.ui.projH.makeImage( projXmin, projXmax, projYmin, projYmax ) diff --git a/pycaqtimage/pycaqtimage.sip b/pycaqtimage/pycaqtimage.sip index 3126f81..8dc310f 100644 --- a/pycaqtimage/pycaqtimage.sip +++ b/pycaqtimage/pycaqtimage.sip @@ -159,6 +159,7 @@ struct ImageBuffer int imgwidth, imgheight; int size; int iRoiW, iRoiH; + uint32_t max_px, min_px; int32_t iProjXmin, iProjXmax; int32_t iProjYmin, iProjYmax; @@ -271,6 +272,8 @@ PyObject* pyCreateImageBuffer(QImage* imageDisp, PyObject *px_, PyObject *py_, P memset(imageBuffer->projSumY, 0, leny * sizeof(double) ); memset(imageBuffer->imageData, 0, imageBuffer->size * sizeof(uint32_t) ); memset(imageBuffer->imageDataF, 0, imageBuffer->size * sizeof(float) ); + imageBuffer->max_px = 0; + imageBuffer->min_px = 0; PyObject* pyImageBuffer = PyCapsule_New(imageBuffer, PYC_IB, _pyFreeImageBuffer); return pyImageBuffer; @@ -506,6 +509,8 @@ static void _computeRoiProj(ImageBuffer* imageBuffer, QRectF* rectRoi, bool bPro double* projSumY = imageBuffer->projSumY; int width = imageBuffer->imgwidth; int height = imageBuffer->imgheight; + uint32_t max_px = 0; + uint32_t min_px = 4294967295; for (int iX = 0; iX < width; projSumX[iX++] = 0); for (int iY = 0; iY < height; projSumY[iY++] = 0); @@ -557,9 +562,14 @@ static void _computeRoiProj(ImageBuffer* imageBuffer, QRectF* rectRoi, bool bPro u64PixelSum += iValue; /* Sigh... if iValue > 49000 or so, the square of an int will be negative! */ u64PixelSqSum += iValue*(uint64_t) iValue; + max_px = std::max(iValue, max_px); + min_px = std::min(iValue, min_px); } } + imageBuffer->max_px = max_px; + imageBuffer->min_px = min_px; + imageBuffer->iRoiW = x2 - x1 + 1; imageBuffer->iRoiH = y2 - y1 + 1; const float w = imageBuffer->iRoiW; @@ -641,8 +651,17 @@ PyObject* pyUpdateProj(PyObject* pyImageBuffer, bool bProjAutoRange, imageBuffer->iProjYmax = uMax; } - return Py_BuildValue("ffiiii", imageBuffer->fRoiPixelMean, imageBuffer->fRoiPixelVar, - imageBuffer->iProjXmin, imageBuffer->iProjXmax, imageBuffer->iProjYmin, imageBuffer->iProjYmax); + return Py_BuildValue( + "ffiiiiii", + imageBuffer->fRoiPixelMean, + imageBuffer->fRoiPixelVar, + imageBuffer->iProjXmin, + imageBuffer->iProjXmax, + imageBuffer->iProjYmin, + imageBuffer->iProjYmax, + imageBuffer->max_px, + imageBuffer->min_px + ); } /*