Ejemplo n.º 1
0
    def asfloat(self, normalise=True, clip=False, clip_negative=False, **kargs):
        """Convert stack to floating point type.
        Analagous behaviour to ImageFile.asfloat()

        If currently an int type and normalise then floats will be normalised
        to the maximum allowed value of the int type.
        If currently a float type then no change occurs.
        If clip_negative then clip values outside the range 0,1

        Keyword Arguments:
            normalise(bool):
                normalise the image to the max value of current int type
            clip(bool):
                clip resulting range to values between -1 and 1
            clip_negative(bool):
                clip range further to 0,1
        """
        if self.imarray.dtype.kind == "f":
            pass
        else:
            self._stack = convert(self._stack, dtype=np.float64, normalise=normalise)
        if "clip_neg" in kargs:
            warnings.warn(
                "clip_neg argument renamed to clip_negative in ImageStack2. This will cause an error in future versions of the Stoner Package."
            )
            clip_negative = kargs.pop("clip_neg")
        if clip or clip_negative:
            self.clip_intensity(clip_negative=clip_negative)
Ejemplo n.º 2
0
    def asfloat(self,
                normalise=True,
                clip=False,
                clip_negative=False,
                **kargs):
        """Convert stack to floating point type.
        Analagous behaviour to ImageFile.asfloat()

        If currently an int type and normalise then floats will be normalised
        to the maximum allowed value of the int type.
        If currently a float type then no change occurs.
        If clip_negative then clip values outside the range 0,1

        Keyword Arguments:
            normalise(bool):
                normalise the image to the max value of current int type
            clip(bool):
                clip resulting range to values between -1 and 1
            clip_negative(bool):
                clip range further to 0,1
        """
        if self.imarray.dtype.kind == "f":
            pass
        else:
            self._stack = convert(self._stack,
                                  dtype=np.float64,
                                  normalise=normalise)
        if "clip_neg" in kargs:
            warnings.warn(
                "clip_neg argument renamed to clip_negative in ImageStack2. This will cause an error in future versions of the Stoner Package."
            )
            clip_negative = kargs.pop("clip_neg")
        if clip or clip_negative:
            self.clip_intensity(clip_negative=clip_negative)
Ejemplo n.º 3
0
    def asfloat(self, normalise=True, clip=False, clip_negative=False):
        """Convert stack to floating point type.
        Analagous behaviour to ImageFile.asfloat()

        If currently an int type and normalise then floats will be normalised 
        to the maximum allowed value of the int type.
        If currently a float type then no change occurs. 
        If clip_negative then clip values outside the range 0,1

        Keyword Arguments:
            normalise(bool):
                normalise the image to the max value of current int type
            clip(bool):
                clip resulting range to values between -1 and 1
            clip_negative(bool):
                clip range further to 0,1
        """
        if self.imarray.dtype.kind == 'f':
            pass
        else:
            self._stack = convert(self._stack,
                                  dtype=np.float64,
                                  normalise=normalise)
        if clip or clip_negative:
            self.clip_intensity(clip_negative=clip_negative)
Ejemplo n.º 4
0
 def asint(self, dtype=np.uint16):
     """convert the image to unsigned integer format. 
     
     May raise warnings about loss of precision. Pass through to skiamge img_as_uint
     """
     if self.dtype.kind == 'f' and (np.max(self) > 1 or np.min(self) < -1):
         self = self.normalise()
     ret = convert(self, dtype)
     return ret
Ejemplo n.º 5
0
 def asfloat(self, normalise=False, clip_negative=False):
     """Return the image converted to floating point type.
     
     If currently an int type then floats will be automatically normalised.
     If currently a float type then will normalise if normalise.
     If currently an unsigned int type then image will be in range 0,1        
     Keyword Arguments:
         normalise(bool):
             normalise the image to -1,1
         clip_negative(bool):
             clip negative intensity to 0
     """
     ret = ImageArray(convert(self, dtype=np.float64))
     if normalise:
         ret = ret.normalise()
     if clip_negative:
         ret = ret.clip_negative()
     return ret