Exemplo n.º 1
0
 def __init__(self, file1, file2, fmin, fmax, gamma=1.0, bb=[0, 0, -1, -1], minquality=1.0):
     self.numerator = FitsData(file1, bb)
     self.denominator = FitsData(file2, bb)
     self.size = self.numerator.size
     if self.size != self.denominator.size:
         raise IndexError, "Incompatible sizes in RatioImage!"
     MyImage.__init__(self, "L", self.size)
     if self.ratiofunc == None:
         self.fitsdata = self.numerator.fitsdata / self.denominator.fitsdata
     else:
         self.fitsdata = self.ratiofunc(self.numerator.fitsdata, self.denominator.fitsdata)
     self.flatnormaldata = (numarray.ravel(self.fitsdata) - fmin) / (fmax - fmin)
     self.flatnormaldata = numarray.clip(self.flatnormaldata, 0.0, 1.0)
     if gamma != 1.0:
         self.flatnormaldata = self.flatnormaldata ** (1.0 / gamma)
     self.putdata(self.flatnormaldata, scale=255.0)
     self.quality = numarray.where(self.denominator.fitsdata > minquality, 1, 0)
     self.quality = numarray.where(self.numerator.fitsdata > minquality, self.quality, 0)
     self.alpha = Image.new("L", self.size)
     self.alpha.putdata(numarray.ravel(self.quality), scale=255)
     self.im = Image.composite(self, Image.new("L", self.size, 255), self.alpha).im
Exemplo n.º 2
0
    def __init__(self, fitsfile, fmin, fmax, gamma=1.0, bb=[0, 0, -1, -1], icut=None, cutaxis=1, takelog=0):
        FitsData.__init__(self, fitsfile, bb, icut, cutaxis)
        MyImage.__init__(self, "L", self.size)
        # 06 Dec 2010: add new attributes: min, max to allow outside inspection
        # 05 Dec 2010: If fmin or fmax is None, then the respective limit is found from the data
        self.min = fmin if not fmin is None else self.fitsdata.min()
        self.max = fmax if not fmax is None else self.fitsdata.max()
        if takelog:
            self.flatnormaldata = (numarray.ravel(numarray.log10(self.fitsdata)) - numarray.log10(self.min)) / (
                numarray.log10(self.max) - numarray.log10(self.min)
            )
        else:
            self.flatnormaldata = (numarray.ravel(self.fitsdata) - self.min) / (self.max - self.min)
        # 09 Sep 2005: How on earth did this ever work before? It is necessary
        # to clip fitsdata to [fmin,fmax] before applying gamma correction, or
        # else we get sqrt of negative numbers....
        # Aha, there is a smart way to do this!
        self.flatnormaldata = numarray.clip(self.flatnormaldata, 0.0, 1.0)

        if gamma != 1.0:
            self.flatnormaldata = self.flatnormaldata ** (1.0 / gamma)
        self.putdata(self.flatnormaldata, scale=255.0)