Beispiel #1
0
    def compute_image(self, idx, NX, NY, rtmin, rtmax, mzmin, mzmax):

        if rtmin >= rtmax or mzmin >= mzmax:
            smoothed = np.zeros((1, 1))
        else:
            # optimized:
            # one additional row / col as we loose one row and col during smoothing:

            # sample_image only works on level1, therefore we have to use getDominatingPeakmap()
            pm = self.peakmaps[idx].getDominatingPeakmap()
            data = sample_image(pm, rtmin, rtmax, mzmin, mzmax, NX + 1, NY + 1)

            smoothed = smooth(data, mzmax, mzmin)
            # enlarge single pixels depending on the mz range in the image:

        # turn up/down
        smoothed = smoothed[::-1, :]
        imin = self.imin
        imax = self.imax

        if self.is_log:
            smoothed = np.log(1.0 + smoothed)
            imin = np.log(1.0 + imin)
            imax = np.log(1.0 + imax)

        # set values out of range to imin, later this is scaled to 0, also black:
        smoothed[smoothed < imin] = imin
        smoothed[smoothed > imax] = imin
        smoothed -= imin

        # scale to 1.0
        maxd = np.max(smoothed)
        if maxd:
            smoothed /= maxd

        # apply gamma
        smoothed = smoothed ** (self.gamma) * 255
        return smoothed.astype(np.uint8)
Beispiel #2
0
    def compute_image(self, idx, NX, NY, rtmin, rtmax, mzmin, mzmax):

        if rtmin >= rtmax or mzmin >= mzmax:
            smoothed = np.zeros((1, 1))
        else:
            # optimized:
            # one additional row / col as we loose one row and col during smoothing:

            # sample_image only works on level1, therefore we have to use getDominatingPeakmap()
            pm = self.peakmaps[idx].getDominatingPeakmap()
            data = sample_image(pm, rtmin, rtmax, mzmin, mzmax, NX + 1, NY + 1)

            smoothed = smooth(data, mzmax, mzmin)
            # enlarge single pixels depending on the mz range in the image:

        # turn up/down
        smoothed = smoothed[::-1, :]
        imin = self.imin
        imax = self.imax

        if self.is_log:
            smoothed = np.log(1.0 + smoothed)
            imin = np.log(1.0 + imin)
            imax = np.log(1.0 + imax)

        # set values out of range to imin, later this is scaled to 0, also black:
        smoothed[smoothed < imin] = imin
        smoothed[smoothed > imax] = imin
        smoothed -= imin

        # scale to 1.0
        maxd = np.max(smoothed)
        if maxd:
            smoothed /= maxd

        # apply gamma
        smoothed = smoothed**(self.gamma) * 255
        return smoothed.astype(np.uint8)
    def compute_image(self, idx, NX, NY, rtmin, rtmax, mzmin, mzmax):

        if rtmin >= rtmax or mzmin >= mzmax:
            dilated = np.zeros((1, 1))
        else:
            # optimized:
            # one additional row / col as we loose one row and col during smoothing:

            # sample_image only works on level1, therefore we have to use getDominatingPeakmap()
            pm = self.peakmaps[idx].getDominatingPeakmap()
            data = sample_image(pm, rtmin, rtmax, mzmin, mzmax, NX + 1, NY + 1)

            imin = self.imin
            imax = self.imax

            if self.is_log:
                data = np.log(1.0 + data)
                imin = np.log(1.0 + imin)
                imax = np.log(1.0 + imax)

            # set values out of range to black:
            overall_max = np.max(data)
            data[data < imin] = 0
            data[data > imax] = 0

            data /= overall_max

            # enlarge peak pixels depending on the mz range in the image:
            dilated = dilate(data, mzmax, mzmin)

        # turn up/down
        dilated = dilated[::-1, :]

        # apply gamma
        dilated = dilated**(self.gamma) * 255
        return dilated.astype(np.uint8)
    def compute_image(self, idx, NX, NY, rtmin, rtmax, mzmin, mzmax):

        if rtmin >= rtmax or mzmin >= mzmax:
            dilated = np.zeros((1, 1))
        else:
            # optimized:
            # one additional row / col as we loose one row and col during smoothing:

            # sample_image only works on level1, therefore we have to use getDominatingPeakmap()
            pm = self.peakmaps[idx].getDominatingPeakmap()
            data = sample_image(pm, rtmin, rtmax, mzmin, mzmax, NX + 1, NY + 1)

            imin = self.imin
            imax = self.imax

            if self.is_log:
                data = np.log(1.0 + data)
                imin = np.log(1.0 + imin)
                imax = np.log(1.0 + imax)

            # set values out of range to black:
            overall_max = np.max(data)
            data[data < imin] = 0
            data[data > imax] = 0

            data /= overall_max

            # enlarge peak pixels depending on the mz range in the image:
            dilated = dilate(data, mzmax, mzmin)

        # turn up/down
        dilated = dilated[::-1, :]

        # apply gamma
        dilated = dilated ** (self.gamma) * 255
        return dilated.astype(np.uint8)