当前位置: 首页>>代码示例>>Python>>正文


Python skimage.filters方法代码示例

本文整理汇总了Python中skimage.filters方法的典型用法代码示例。如果您正苦于以下问题:Python skimage.filters方法的具体用法?Python skimage.filters怎么用?Python skimage.filters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skimage的用法示例。


在下文中一共展示了skimage.filters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __calc_gradient_histogram

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import filters [as 别名]
def __calc_gradient_histogram(self, label, gaussian, n_region, nbins_orientation = 8, nbins_inten = 10):
        op = numpy.array([[-1, 0, 1]], dtype=numpy.float32)
        h = scipy.ndimage.filters.convolve(gaussian, op)
        v = scipy.ndimage.filters.convolve(gaussian, op.transpose())
        g = numpy.arctan2(v, h)

        # define each axis for texture histogram
        bin_width = 2 * math.pi / 8
        bins_label = range(n_region + 1)
        bins_angle = numpy.linspace(-math.pi, math.pi, nbins_orientation + 1)
        bins_inten = numpy.linspace(.0, 1., nbins_inten + 1)
        bins = [bins_label, bins_angle, bins_inten]

        # calculate 3 dimensional histogram
        ar = numpy.vstack([label.ravel(), g.ravel(), gaussian.ravel()]).transpose()
        hist = numpy.histogramdd(ar, bins = bins)[0]

        # orientation_wise intensity histograms are serialized for each region
        return numpy.reshape(hist, (n_region, nbins_orientation * nbins_inten)) 
开发者ID:belltailjp,项目名称:selective_search_py,代码行数:21,代码来源:features.py

示例2: difference_of_gaussian

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import filters [as 别名]
def difference_of_gaussian(self, imin, bigsize=30.0, smallsize=3.0):
        g1 = filters.gaussian_filter(imin, bigsize)
        g2 = filters.gaussian_filter(imin, smallsize)
        diff = 255*(g1 - g2)

        diff[diff < 0] = 0.0
        diff[diff > 255.0] = 255.0
        diff = diff.astype(np.uint8) 
               
        return diff 
开发者ID:PeterJackNaylor,项目名称:DRFNS,代码行数:12,代码来源:segmentation_test.py

示例3: get_bin_threshold

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import filters [as 别名]
def get_bin_threshold(self, percent, high=True, adaptive=False, binary=True, img=False):
        """
        Threshold the image into binary values
        
        Parameters
        ----------
        percent : float
            The percentage where the thresholding is made
        high : bool
            If high a value of 1 is returned for values > percent
        adaptive : bool
            If True, performs an adaptive thresholding (see skimage.filters.threshold_adaptive)
        binary : bool
            If True return bool data (True/False) otherwise  numeric (0/1)
        img : bool
            If True return a SPM_image otherwise a numpy array
        """
        if adaptive:
            if binary:
                return self.pixels > threshold_local(self.pixels, percent)
            return threshold_local(self.pixels, percent)
        mi = np.min(self.pixels)
        norm = (self.pixels-mi)/(np.max(self.pixels)-mi)
        if high:
            r = norm > percent
        else:
            r = norm < percent
        if not img:
            if binary:
                return r
            return np.ones(self.pixels.shape)*r
        else:
            I = copy.deepcopy(self)
            I.channel = "Threshold from "+I.channel
            if binary:
                I.pixels = r
            else:
                I.pixels = np.ones(self.pixels.shape)*r
            return I 
开发者ID:scholi,项目名称:pySPM,代码行数:41,代码来源:SPM.py

示例4: identifyBlurryRegions

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import filters [as 别名]
def identifyBlurryRegions(s, params):
    logging.info(f"{s['filename']} - \tidentifyBlurryRegions")

    blur_radius = int(params.get("blur_radius", 7))
    blur_threshold = float(params.get("blur_threshold", .1))

    img = s.getImgThumb(params.get("image_work_size", "2.5x"))
    img = rgb2gray(img)
    img_laplace = np.abs(skimage.filters.laplace(img))
    mask = skimage.filters.gaussian(img_laplace, sigma=blur_radius) <= blur_threshold

    mask = skimage.transform.resize(mask, s.getImgThumb(s["image_work_size"]).shape, order=0)[:, :,
           1]  # for some reason resize takes a grayscale and produces a 3chan
    mask = s["img_mask_use"] & (mask > 0)

    io.imsave(s["outdir"] + os.sep + s["filename"] + "_blurry.png", img_as_ubyte(mask))
    s["img_mask_blurry"] = (mask * 255) > 0

    prev_mask = s["img_mask_use"]
    s["img_mask_use"] = s["img_mask_use"] & ~s["img_mask_blurry"]

    s.addToPrintList("percent_blurry",
                     printMaskHelper(params.get("mask_statistics", s["mask_statistics"]), prev_mask, s["img_mask_use"]))

    if len(s["img_mask_use"].nonzero()[0]) == 0:  # add warning in case the final tissue is empty
        logging.warning(
            f"{s['filename']} - After BlurDetectionModule.identifyBlurryRegions NO tissue remains detectable! Downstream modules likely to be incorrect/fail")
        s["warnings"].append(
            f"After BlurDetectionModule.identifyBlurryRegions NO tissue remains detectable! Downstream modules likely to be incorrect/fail")


    return 
开发者ID:choosehappy,项目名称:HistoQC,代码行数:34,代码来源:BlurDetectionModule.py

示例5: __init_texture

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import filters [as 别名]
def __init_texture(self, n_region):
        gaussian = skimage.filters.gaussian_filter(self.image, sigma = 1.0, multichannel = True).astype(numpy.float32)
        r_hist = self.__calc_gradient_histogram(self.label, gaussian[:, :, 0], n_region)
        g_hist = self.__calc_gradient_histogram(self.label, gaussian[:, :, 1], n_region)
        b_hist = self.__calc_gradient_histogram(self.label, gaussian[:, :, 2], n_region)

        hist = numpy.hstack([r_hist, g_hist, b_hist])
        l1_norm = numpy.sum(hist, axis = 1).reshape((n_region, 1))

        hist = numpy.nan_to_num(hist / l1_norm)
        return {i : hist[i] for i in range(n_region)} 
开发者ID:belltailjp,项目名称:selective_search_py,代码行数:13,代码来源:features.py


注:本文中的skimage.filters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。