Page MenuHomePhabricator

coremodification.diff

Authored By
fritzsck
Sep 30 2010, 3:09 PM
Size
6 KB
Referenced Files
None
Subscribers
None

coremodification.diff

Index: mitk/Core/Code/Rendering/mitkImageMapperGL2D.cpp
===================================================================
--- mitk/Core/Code/Rendering/mitkImageMapperGL2D.cpp (revision 26476)
+++ mitk/Core/Code/Rendering/mitkImageMapperGL2D.cpp (working copy)
@@ -938,6 +938,7 @@
rendererInfo.m_TextureInterpolation = textureInterpolation;
mitk::LevelWindow levelWindow;
+ mitk::LevelWindow opacLevelWindow;
bool binary = false;
this->GetDataNode()->GetBoolProperty( "binary", binary, renderer );
@@ -946,6 +947,7 @@
{
image->setExtrema(0, 1);
+ image->setOpacityExtrema( 0.0, 255.0 );
image->setBinary(true);
bool binaryOutline = false;
@@ -977,7 +979,17 @@
this->GetLevelWindow( levelWindow, renderer );
}
- image->setExtrema( levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound() );
+ image->setExtrema( levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound() );
+
+ // obtain opacity level window
+ if( this->GetLevelWindow( opacLevelWindow, renderer, "opaclevelwindow" ) )
+ {
+ image->setOpacityExtrema( opacLevelWindow.GetLowerWindowBound(), opacLevelWindow.GetUpperWindowBound() );
+ }
+ else
+ {
+ image->setOpacityExtrema( 0.0, 255.0 );
+ }
}
bool useColor = false;
Index: mitk/Utilities/IIL4MITK/picimage.cpp
===================================================================
--- mitk/Utilities/IIL4MITK/picimage.cpp (revision 26476)
+++ mitk/Utilities/IIL4MITK/picimage.cpp (working copy)
@@ -72,6 +72,49 @@
}
void
+ iil4mitkPicImage::setOpacityExtrema (const float minimum, const float maximum)
+{
+ // assert (minimum < maximum);
+
+ _minOpac = minimum;
+ _maxOpac = maximum;
+ invalidateTextures ();
+}
+
+void
+iil4mitkPicImage::setOpacityWindow (const float level, const float window)
+{
+ // assert (window > 0);
+ _minOpac = level - window / 2.0;
+ _maxOpac = _minOpac + window;
+ invalidateTextures ();
+}
+
+float
+iil4mitkPicImage::minimumOpacity () const
+{
+ return _minOpac;
+}
+
+float
+iil4mitkPicImage::maximumOpacity () const
+{
+ return _maxOpac;
+}
+
+float
+iil4mitkPicImage::levelOpacity () const
+{
+ return (_minOpac + _maxOpac) / 2.0;
+}
+
+float
+iil4mitkPicImage::windowOpacity () const
+{
+ return (_maxOpac - _minOpac);
+}
+
+void
iil4mitkPicImage::setColors (const unsigned char* colors)
{
_colors = colors;
@@ -147,6 +190,7 @@
{
_pic = NULL;
_min = _max = 0.0;
+ _minOpac = _maxOpac = 0.0;
_colors = NULL;
_binary = false;
_mask = false;
@@ -417,6 +461,8 @@
unsigned int slice = _pic->n[0] * _pic->n[1] * (_pic->bpe / 8);
float scale = (_max -_min > 0 ? 255.0 / (_max - _min) : 0.0);
float bias = _min * scale;
+ float scaleOpac = (_maxOpac -_minOpac > 0 ? 255.0 / (_maxOpac - _minOpac) : 0.0);
+ float biasOpac = _minOpac * scaleOpac;
unsigned char *src = (unsigned char *) _pic->data + (y * _pic->n[0] + x) * (_pic->bpe/8);
unsigned char *dst = data + (yoffset * width + xoffset) * (bpe () / 8);
unsigned char *eol = dst + w * (bpe () / 8);
@@ -464,24 +510,30 @@
unsigned char* dest = dst;
while (dest < eol)
{
- if(_min!=0 || _max!=255)
+ if(_min!=0 || _max!=255 || _minOpac!=0 || _maxOpac!=255)
{
+ double rgb[3], alpha, hsi[3];
+
// level/window mechanism for intensity in HSI space
- double rgb[3], hsi[3];
rgb[0] = source[0];
rgb[1] = source[1];
rgb[2] = source[2];
+ alpha = source[3];
RGBtoHSI<double>(rgb,hsi);
hsi[2] = hsi[2] * 255.0 * scale - bias;
hsi[2] = (hsi[2] > 255.0 ? 255 : (hsi[2] < 0.0 ? 0 : hsi[2]));
hsi[2] /= 255.0;
HSItoRGB<double>(hsi,rgb);
+
+ // level/window mechanism for opacity
+ alpha = alpha * scaleOpac - biasOpac;
+ alpha = (alpha > 255.0 ? 255 : (alpha < 0.0 ? 0 : alpha));
+
dest[0] = (unsigned char)rgb[0];
dest[1] = (unsigned char)rgb[1];
dest[2] = (unsigned char)rgb[2];
+ dest[3] = (unsigned char)alpha;
- dest[3] = source[3];
-
source+=4;
dest+=4;
}
Index: mitk/Utilities/IIL4MITK/picimage.h
===================================================================
--- mitk/Utilities/IIL4MITK/picimage.h (revision 26476)
+++ mitk/Utilities/IIL4MITK/picimage.h (working copy)
@@ -45,7 +45,7 @@
/*!
\brief Sets the range of the intensities which will be displayed.
@param level the level of the window
- @param window the width of the window
+ @param window the width of the window
*/
void setWindow (const float level, const float window);
@@ -60,18 +60,54 @@
float maximum () const;
/*!
- \brief Gets the level of the window which limits the
+ \brief Gets the level of the window which limits the
displayed intensities.
*/
float level () const;
/*!
- \brief Gets the width of the window which limits the
+ \brief Gets the width of the window which limits the
displayed intensities.
*/
float window () const;
/*!
+ \brief Sets the range of opacity values which will be displayed.
+ @param minimum the minimal opacity
+ @param maximum the maximal opacity
+ */
+ void setOpacityExtrema (const float minimum, const float maximum);
+
+ /*!
+ \brief Sets the range of the opacities which will be displayed.
+ @param level the level of the window
+ @param window the width of the window
+ */
+ void setOpacityWindow (const float level, const float window);
+
+ /*!
+ \brief Gets the minimal opacity which will be displayed.
+ */
+ float minimumOpacity () const;
+
+ /*!
+ \brief Gets the maximal opacity which will be displayed.
+ */
+ float maximumOpacity () const;
+
+ /*!
+ \brief Gets the level of the window which limits the
+ displayed opacities.
+ */
+ float levelOpacity () const;
+
+ /*!
+ \brief Gets the width of the window which limits the
+ displayed opacities.
+ */
+ float windowOpacity () const;
+
+ /*!
\brief Sets the color map which assigns each intensity
a color according to the color model.
@param colors the array of colors using either the
@@ -153,6 +189,11 @@
float _min, _max;
/*!
+ \brief The extremal opacity values.
+ */
+ float _minOpac, _maxOpac;
+
+ /*!
\brief The color map.
*/
const unsigned char* _colors;

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
579
Default Alt Text
coremodification.diff (6 KB)

Event Timeline

changes in picimage and 2D image mapper