• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python filters.gaussian_filter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: showAttMap

def showAttMap(img, attMaps, tagName, overlap = True, blur = False):
    pylab.rcParams['figure.figsize'] = (12.0, 12.0)
    f, ax = plt.subplots(len(tagName)/2+1, 2)
    if len(ax.shape) == 1:
        ax[0].imshow(img)
    else:
        ax[0, 0].imshow(img)
    
    for i in range(len(tagName)):
        attMap = attMaps[i].copy()
        attMap -= attMap.min()
        if attMap.max() > 0:
            attMap /= attMap.max()
        attMap = transform.resize(attMap, (img.shape[:2]), order = 3, mode = 'nearest')
        if blur:
            attMap = filters.gaussian_filter(attMap, 0.02*max(img.shape[:2]))
            attMap -= attMap.min()
            attMap /= attMap.max()
    
        cmap = plt.get_cmap('jet')
        attMapV = cmap(attMap)
        attMapV = np.delete(attMapV, 3, 2)
        if overlap:
            attMap = 1*(1-attMap**0.8).reshape(attMap.shape + (1,))*img + (attMap**0.8).reshape(attMap.shape+(1,)) * attMapV;
        if len(ax.shape) == 1:
            ax[i+1].imshow(attMap, interpolation = 'bicubic')
            ax[i+1].set_title(tagName[i])
        else:  
            ax[(i+1)/2, (i+1)%2].imshow(attMap, interpolation = 'bicubic')
            ax[(i+1)/2, (i+1)%2].set_title(tagName[i])
开发者ID:jimmie33,项目名称:Caffe-ExcitationBP,代码行数:30,代码来源:util.py


示例17: spatialSmoothing

def spatialSmoothing(X, x, y, z, gamma, sigma):
    # loop through the collumns of the data for each row
    newX = X
    for i in range(0, 501): # Do the rows
        for j in range(0, 5903):
            trans = []
            # insert the current voxel into both lists
            trans.append(X[i,j])
            x1 = x[j]
            y1 = y[j]
            z1 = z[j]
            for k in range(0, 5903):
                x2 = x[k]
                y2 = y[k]
                z2 = z[k]
                dist =[]
                dist.append(0)
                # Decide if the x,y,z components of the thing is close enough
                if(k != j and dist(x1,y1,z1,x2,y2,z2) <= gamma):
                    trans.append(X[i,k])
                    dist.append(dist(x1,y1,z1,x2,y2,z2))
            # Now go through and put the order of the array as distance to the first
            for i in range(0, len(x)):
                for j in range(i+1, len(x)):
                    if( dist[j] < dist[i] ):
                        dist[j], dist[i] = dist[i], dist[j]
                        trans[j], trans[i] = trans[i], trans[j]
            if( len(trans) > 1 ):
                filterTrans = filters.gaussian_filter(trans, sigma, output=True)
            # First value of filterTrans is what you want to keep
            # Replace it with the previous value in the newX
            newX[i,j] = filterTrans[0]
    return newX
开发者ID:colegulino,项目名称:Machine-Learning-on-fMRI-Data,代码行数:33,代码来源:smoothTest.py


示例18: run

	def run(self):
		if not os.path.exists(self.output_dir):
			os.makedirs(self.output_dir)
			print 'USER INFO: Creando carpeta de listas de archivos con imágenes en ' + self.output_dir
		jpgs_lib = os.listdir(self.input().path)
		resultado = []
		for jpg in jpgs_lib:
			ruta_jpg = os.path.join(self.input().path,jpg)
			print '====================='
			print 'USER INFO: ' + ruta_jpg
			try:
				pagina = misc.imread(ruta_jpg)
				pagina = rgb2gray(pagina)
				pagina = gaussian_filter(pagina,sigma=2) #Un filtro que me de un promedio de la imagen
				if pagina.var() > self.varianza:
					resultado.append(jpg.replace('.jpg',''))
				print 'USER INFO: Var = ', pagina.var()
				print '====================='
				# resultado.append('basura')
			except:
				print 'USER WARNING: No se pudo leer la imagen ' + ruta_jpg

		resultado = '\n'.join(resultado)
		with self.output().open("w") as f:
			f.write(resultado)


# if __name__ == '__main__':
	# luigi.run()
开发者ID:andreslechuga,项目名称:arte_mexicano_antiguo,代码行数:29,代码来源:data_flow_jared_modif.py


示例19: segment_cells

def segment_cells(frame, mask=None):
    """
    Compute the initial segmentation based on ridge detection + watershed.
    This works reasonably well, but is not robust enough to use by itself.
    """
    
    blurred = filters.gaussian_filter(frame, 2)
    ridges = enhance_ridges(frame)
    
    # threshold ridge image
    thresh = filters.threshold_otsu(ridges)
    thresh_factor = 0.6
    prominent_ridges = ridges > thresh_factor*thresh
    prominent_ridges = morphology.remove_small_objects(prominent_ridges, min_size=256)
    prominent_ridges = morphology.binary_closing(prominent_ridges)
    prominent_ridges = morphology.binary_dilation(prominent_ridges)
    
    # skeletonize
    ridge_skeleton = morphology.medial_axis(prominent_ridges)
    ridge_skeleton = morphology.binary_dilation(ridge_skeleton)
    ridge_skeleton *= mask
    ridge_skeleton -= mask
    
    # label
    cell_label_im = measure.label(ridge_skeleton)
    
    # morphological closing to fill in the cracks
    for cell_num in range(1, cell_label_im.max()+1):
        cell_mask = cell_label_im==cell_num
        cell_mask = morphology.binary_closing(cell_mask, disk(3))
        cell_label_im[cell_mask] = cell_num
    
    return cell_label_im 
开发者ID:brikeats,项目名称:Cell-Tracking,代码行数:33,代码来源:track_cell.py


示例20: run

	def run(self):
		if not os.path.exists(self.output_dir):
			os.makedirs(self.output_dir)
			print 'USER INFO: Creando carpeta de listas de archivos con imagenes en ' + self.output_dir
		
		resultado = []

		try:
			list_jpgs = os.listdir(os.path.join(self.input().path, "jpg"))
					
			for jpg in list_jpgs:
				try:
					#Creamos la ruta para cada jpg
					ruta_jpg = os.path.join(self.input().path,"jpg",jpg)
					#abrimos cada jpg y checamos su varianza, si es alta la guardamos
					pagina = io.imread(ruta_jpg)
					pagina = rgb2gray(pagina)
					pagina = gaussian_filter(pagina,sigma=2) #Un filtro que me de un promedio de la imagen
					if pagina.var() > self.varianza:
						resultado.append(ruta_jpg)
				except:
					pass
		except:
			pass		
		
		resultado = '\n'.join(resultado)
		with self.output().open("w") as f:
			f.write(resultado)
开发者ID:felipegerard,项目名称:arte_mexicano_antiguo,代码行数:28,代码来源:data_flow_jared.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python filters.sobel函数代码示例发布时间:2022-05-27
下一篇:
Python filters.gaussian函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap