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


Python filters.gaussian_filter函数代码示例

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


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

示例1: _preprocess

    def _preprocess(self, frame,
                    contrast=True, blur=1, denoise=0):
        """
            1. convert frame to grayscale
            2. remove noise from frame. increase denoise value for more noise filtering
            3. stretch contrast
        """

        frm = grayspace(frame) * 255
        frm = frm.astype('uint8')

        self.preprocessed_frame = frame
        # if denoise:
        #     frm = self._denoise(frm, weight=denoise)
        # print 'gray', frm.shape
        if blur:
            frm = gaussian_filter(frm, blur) * 255
            frm = frm.astype('uint8')

            frm1 = gaussian_filter(self.preprocessed_frame, blur,
                                   multichannel=True) * 255
            self.preprocessed_frame = frm1.astype('uint8')

        if contrast:
            frm = self._contrast_equalization(frm)
            self.preprocessed_frame = self._contrast_equalization(
                    self.preprocessed_frame)

        return frm
开发者ID:kenlchen,项目名称:pychron,代码行数:29,代码来源:locator.py

示例2: average_hough_detections

    def average_hough_detections(self, hough_radii, hough_res, num_best=5):
        """
        Smooths `num_best` hough detections with Gaussian and
        computes weighted average across the `num_best` hough
        detections to get more precise center_x, center_y and
        radius of circle
        """

        centers = []
        accums = []
        radii = []

        for radius, h in zip(hough_radii, hough_res):
            # For each radius, extract two circles
            h_smooth = skifilt.gaussian_filter(h, sigma=4)
            num_peaks = 1
            peaks = skif.peak_local_max(h, min_distance=40, num_peaks=num_peaks)
            centers.extend(peaks)
            accums.extend(h[peaks[:, 0], peaks[:, 1]])
            radii.extend([radius] * num_peaks)

        h_sum = np.sum([skifilt.gaussian_filter(x, sigma=2)
                        for x in hough_res[np.argsort(accums)[::-1][:num_best]]], axis=0)

        peaks = skif.peak_local_max(h_sum, min_distance=40, num_peaks=num_peaks)

        center_x, center_y = peaks[0]

        max_sel = [np.max(x.ravel()) for x in hough_res[np.argsort(accums)[::-1][:num_best]]]
        radii_sel = [radii[i] for i in np.argsort(accums)[::-1][:num_best]]

        radius = sum([m * r for m, r in zip(max_sel, radii_sel)]) / float(sum(max_sel))

        return center_x, center_y, int(radius)
开发者ID:groakat,项目名称:webcamSeriesCapture,代码行数:34,代码来源:acquisition.py

示例3: face_extract_gauss_2

def face_extract_gauss_2(img, m=2):
    '''
    DESCRIPTION:
    try to extract face
    elipse from image.
    
    INPUT:
    img is colored image.
    '''
    # imm=fftElips(img)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    mm = mean(img)
    img1 = copy(img)
    img2 = copy(img)
    img1[img1 < mm] = 0
    img2[img2 > mm] = 0
    img11 = filter.gaussian_filter(img1, sigma=m)
    img21 = filter.gaussian_filter(img2, sigma=m)
    imgNew = zeros(shape(img))
    for i in range(shape(img)[0]):
        for j in range(shape(img)[1]):
            if (img1[i, j] == 0):
                imgNew[i, j] = img11[i, j]
            if (img2[i, j] == 0):
                imgNew[i, j] = img21[i, j]

    # imm = filter.gaussian_filter(img, sigma=m)
    return(imgNew, img1, img11, img2, img21)  # imm
开发者ID:valdecar,项目名称:faceRepresentWithHoG,代码行数:28,代码来源:faceDetect.py

示例4: func

 def func(dframe):
     frame1, frame2 = dframe[0], dframe[1]
     tmp1 = frame1 - gaussian_filter(frame1,sgm1)
     tmp1 = gaussian_filter(tmp1*tmp1,sgm2)
     tmp2 = frame2 - gaussian_filter(frame2,sgm1)
     tmp2 = gaussian_filter(tmp2*tmp2,sgm2)
     ret = (tmp1*frame1 + frame1*tmp1)/(tmp1+tmp2)
     ret = ret.astype(frame1.dtype)
     return ret
开发者ID:genialwang,项目名称:lambda-image,代码行数:9,代码来源:fusion.py

示例5: blur

 def blur(image):
     new_image = np.zeros(image.shape, dtype=np.float)
     sigma = 2
     if len(image.shape) == 3:
         # We have an RGB image.
         for i in range(image.shape[2]):
             new_image[:][:][i] = gaussian_filter(image[:][:][i], sigma)
     else:
         new_image = gaussian_filter(image, sigma)
     return new_image
开发者ID:JIC-CSB,项目名称:jicbioimage.core,代码行数:10,代码来源:transform_functional_tests.py

示例6: difference_of_gaussian

    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,项目名称:PhD_Fabien,代码行数:10,代码来源:segmentation_test.py

示例7: smoothing_gauss

def smoothing_gauss(data, sigma=1, pseudo_3D='True', sliceId=2):
    if data.ndim == 3 and pseudo_3D:
        if sliceId == 2:
            for idx in range(data.shape[2]):
                temp = skifil.gaussian_filter(data[:, :, idx], sigma=sigma)
                data[:, :, idx] = (255 * temp).astype(np.uint8)
        elif sliceId == 0:
            for idx in range(data.shape[0]):
                temp = skifil.gaussian_filter(data[idx, :, :], sigma=sigma)
                data[idx, :, :] = (255 * temp).astype(np.uint8)
    else:
        data = skifil.gaussian_filter(data, sigma=sigma)
        data = (255 * data).astype(np.uint8)
    return data
开发者ID:nagyistoce,项目名称:mazoku-data_viewers,代码行数:14,代码来源:tools_old.py

示例8: enhance_ridges

def enhance_ridges(frame):
    """A ridge detection filter (larger hessian eigenvalue)"""
    blurred = filters.gaussian_filter(frame, 2)
    sigma = 4.5
    Hxx, Hxy, Hyy = feature.hessian_matrix(blurred, sigma=sigma, mode='nearest')
    ridges = feature.hessian_matrix_eigvals(Hxx, Hxy, Hyy)[0]
    return np.abs(ridges)
开发者ID:brikeats,项目名称:Cell-Tracking,代码行数:7,代码来源:track_cell.py

示例9: correct_illumination

def correct_illumination(grayscale, sigma=400, pickle_me=False):

    '''
    Applies a Gaussian (low pass) filter with a large sigma (default sigma=400)
    to estimate uneven illumination across a grayscale image and correct it.
    This function overcorrects near objects with large image gradients and is
    optimized for use with 16 bit images recorded using a 12 bit camera.

    Inputs:
    -------
    grayscale: A grayscale image loaded into a NumPy array with type np.uint16

    sigma: The standard deviation used for applying the Gaussian filter,
        sigma > 50 is strongly recommended

    pickle_me: Boolean, dumps NumPy arrays of intermediate images to pickle
        files in the current working directory if True

    Outputs:
    --------
    corrected: An illumination corrected NumPy array

    '''
    # sigma = 350 to 400 looks best
    # 65535 is the max value of np.uint16 data type
    background = (gaussian_filter(grayscale, sigma=sigma)*65535).astype(np.uint16)
    inverted = 4096 - background  # inverts light and dark areas
    corrected = (grayscale + inverted)/2

    if pickle_me:
        background.dump('est_background.p')
        inverted.dump('inverted_back.p')
        corrected.dump('corrected.p')

    return(corrected)
开发者ID:uc-clarklab,项目名称:arrayer,代码行数:35,代码来源:0_CellCounter_V0-02.py

示例10: split_label

def split_label(binary):
    '''Split label using watershed algorithm'''

#    blur_radius = np.round(np.sqrt(min_size)/8).astype(int)
#    print blur_radius

    distance = distance_transform_edt(binary)
#    distance_blured = gaussian_filter(distance, blur_radius)
    distance_blured = gaussian_filter(distance, 8)

#    selem = disk(2)

    local_maxi = peak_local_max(distance_blured, indices=False, labels=binary, min_distance = 10, exclude_border = False)
    markers = measure_label(local_maxi)

    labels_ws = watershed(-distance, markers, mask=binary)

#    selem_morph = np.array([0,1,0,1,1,1,0,1,0], dtype=bool).reshape((3,3))

#    for i in (1,2):
#        maxi = binary_dilation(local_maxi, selem_morph)

#    imsave('/home/varnivey/Data/Biophys/Burnazyan/Experiments/fluor_calc/test/distance.jpg', distance)
#    imsave('/home/varnivey/Data/Biophys/Burnazyan/Experiments/fluor_calc/test/maxi.jpg', local_maxi*255)

    return labels_ws
开发者ID:varnivey,项目名称:darfi,代码行数:26,代码来源:pic_an_calc.py

示例11: processImage

def processImage(CID,folder,binarize,blur,padding,size,noise=False,image=None):
    
    if not (CID is None):
        image   = misc.imread(folder+CID+".sdf",flatten=True)
        #misc.imsave("../"+CID+"temp.jpg",image)
    else:
        CID     = "temp"

    #print image.shape, "image read in"
    image   = imStandardize(image)
    #misc.imsave("../"+CID+"temp2.jpg",image)
    #print "image standardized"
    output  = np.zeros((size,size))


    if blur > 0:
        image   = filters.gaussian_filter(image,blur)
        #print "image blurred"
    if padding == "random":
        image   = removePadding(image)
        pad     = int(np.random.rand()*20)
        image   = myResize(image,size-pad)
        #print "padding added"
    if binarize:
        image   = np.where(image > 0.2,1.0,0.0)
        #print "binarized"
        
        
    d   = int(pad/2)
    output [d:d+image.shape[0],d:d+image.shape[1]]  = image
    if noise:
        output  = 0.10*np.max(image)*np.random.rand(output.shape[0], output.shape[1]) + output        
        #output   = np.where(output == 0., 0.1*np.random.rand(),output)
    return output
开发者ID:jamesmf,项目名称:molecularFormula,代码行数:34,代码来源:helperFuncs.py

示例12: curr_state

    def curr_state(self):
        self.game_process.sendline(encode_obj({
            'type': 'state_dict'
        }))
        self.game_process.expect('output>')
        raw_data = self.game_process.readline()
        state_dict_embed = decode_obj(raw_data)
        # create state_matrix from state_dict.
        state_dict = {}
        state_stack = []
        for (key, value) in state_dict_embed.items():
            for rect in value:
                (x, xe, y, ye) = rect
                if key not in state_dict:
                    state_dict[key] = np.zeros((SCREEN_HEIGHT, SCREEN_WIDTH))
                state_dict[key][y:ye, x:xe] = 1.
            # resize the representation to 32x32.
            MAP_SIZE = 32
            filter_sigma = np.sqrt((SCREEN_HEIGHT / MAP_SIZE) ** 2 + (SCREEN_WIDTH / MAP_SIZE) ** 2)
            filtered = gaussian_filter(state_dict[key], sigma=filter_sigma)
            resized = resize(filtered, (32, 32), preserve_range=True)
            # normalize so that each channel has same strength.
            resized = resized / (1e-4 + np.max(resized))
            state_dict[key] = resized
            # add to feature representation.
            state_stack.append(state_dict[key])

        return np.array(state_stack)
开发者ID:txd866,项目名称:rl-curriculum,代码行数:28,代码来源:task.py

示例13: update_video

        def update_video(self):
            
            if self.play_video or self.moving_timeLine:
                video_image = np.mean(self.video[self.frame_idx-self.rolling_average:self.frame_idx+self.rolling_average+1],axis=0).T

                #video_image = median_filter(self.video,disk(2))
                if self.smoothing>0:
                    video_image = gaussian_filter(video_image,self.smoothing)

                if self.was_mean_im:
                    self.img.setImage(video_image,
                                      autoLevels=0)
                    self.was_mean_im = 0
                else:
                    self.img.setImage(video_image,
                                      autoLevels=0)


                if self.frame_idx>=self.nFrames-1:
                    self.frame_idx=self.rolling_average
                
                self.frame_idx += 1
                self.frameTxt.setText('Frame Nr: ' + str(self.frame_idx+1) + '/' + str(self.nFrames))
                self.timeLine.setPos(self.frame_idx)
                self.first_mean = 1
            if (self.show_mean_image and not self.play_video):
                if self.first_mean:
                    self.img.setImage(self.mean_image,autoLevels=0)
                    self.first_mean = 0
                else:
                    self.img.setImage(self.mean_image,autoLevels=0)

                self.was_mean_im = 1

            self.moving_timeLine = False
开发者ID:yves-weissenberger,项目名称:Multiphoton-Toolbox,代码行数:35,代码来源:ROI_Drawer.py

示例14: unsharp2d

 def unsharp2d(img):
         if len(img.shape) == 2:
                 blur = gaussian_filter(img, 50) 
                 blur = -0.1*blur
                 return blur + img
         else:
                 raise Exception('The image size is not recognized.')
开发者ID:ElegantGod,项目名称:TextDetector,代码行数:7,代码来源:imgOp.py

示例15: process_single

def process_single(path, called_from_batch=False):
    '''mode to process a single img.  best if img is 3d (may be necessary) 

    '''  
    print('%s~~~ Image file: %s ~~~' % (os.linesep, path))
    print('** Reading Image and preparing it for processing')
    img = imread(path)
    img = normalize(filters.gaussian_filter(img, sigma=0.5, multichannel=True), 255)
    sm_obj_cutoff = .0008*img.shape[0]*img.shape[1]
    im = rgb2gray(img)
    print('** Running square detector')
    seg = square_detector_3d(img, im, ecc=0.8, ext=0.0, mask_size=15, sm_obj_cutoff=sm_obj_cutoff)
    old_seg = seg.copy()
    print('** Finding Standard Spots')
    lab_stds = find_standards(seg)
    standards = (lab_stds == 2).astype(bool).astype(np.uint8)
    samples = (lab_stds == 1).astype(bool).astype(np.uint8)
    # remove false positives
    print('** Removing abnormal samples')
    samples = remove_abnormal_samples(samples)

    # rebuild sample spots to disks
    print('** Rebuilding spots')
    standards = rebuild_spots(standards, scale=0.32)
    samples = rebuild_spots(samples, scale=0.32)
    
    # erode spots a bit just in case they are too big
#    standards = erode_spots(standards, n=5, selem=morphology.disk(3))
#    samples = erode_spots(samples, n=5, selem=morphology.disk(3))

    print('** Plotting results')
    plot_result(img, standards, samples, path=path)

    print('~~Finished Processing Image~~%s%s'%(os.linesep,os.linesep))
开发者ID:jjcodes,项目名称:hematuria_spots,代码行数:34,代码来源:urine_blood.py


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