当前位置: 首页 > news >正文

医疗软件网站建设公司排名常州网站建设书生商友

医疗软件网站建设公司排名,常州网站建设书生商友,网站字体特效,wordpress emoji表情仔细看这个图像。然后后退几米再看。你看到了什么?混合图像是指将一张图片的低频与另一张图片的高频相结合的图片。根据观看距离的不同,所得到的图像有两种解释。在上面的图片中,你可以看到阿尔伯特爱因斯坦,一旦你离开屏幕或缩小…

仔细看这个图像。然后后退几米再看。你看到了什么?

混合图像是指将一张图片的低频与另一张图片的高频相结合的图片。根据观看距离的不同,所得到的图像有两种解释。在上面的图片中,你可以看到阿尔伯特·爱因斯坦,一旦你离开屏幕或缩小观众的图像大小,他就变成了玛丽莲·梦露。这个概念是在2006年的论文中提出的。为了实现这一效果,您必须实现低通和高通滤波操作来应用于您选择的两幅图像,并线性组合过滤后的图像,得到具有所需的两种解释的混合图像,即最后将只有低频信息的图片和只有高频信息的图像叠加在一起。

对于图像的低频部分:可以理解为图像的“轮廓”,比如一幅画的线条等。

对于图像的高频部分:可以理解为图像的“细节”,比如一幅画的颜色搭配,颜色深度等。

值得一提的是:对图像做模糊处理后得到了图像的低频部分,对图像做锐化处理会让图像的高频信息更多。

实现过滤功能

步骤

您的目标是在hybrid.py中实现以下函数:

  1. cross_correlation_2d:实现了你的过滤功能的核心;

  1. convolve_2d:必须使用cross_correlation_2d功能;

  1. gaussian_blur_kernel_2d:你在这里创建的高斯核,与convolve_2d配对,创建一个高斯模糊滤波器;

  1. low_pass:从图像中删除细节,你的实现必须使用高斯模糊;

  1. high_pass:保留很细的细节和删除低频,您的实现必须使用高斯模糊作为一个子例程。

注意,您必须从头开始实现所有的函数,只使用基本的矩阵操作,而任何来自NumPy、OpenCV、Scipy或类似包的任何过滤函数都是禁止的。功能,如填充,创建网格网格,等。被认为是基本的操作,如果您想快速编写代码并避免多个嵌套的Python循环,则是允许的。

生成混合图像

一旦在hybrid.py中实现了函数,使用提供的创建混合图像。然而,创建一个被我们的大脑很好地解释的混合图像的一个重要因素是对齐两个图像的显著特征。注意:如果您使用多个嵌套的Python循环来实现过滤操作,那么您的函数可能会非常慢。在更改参数后,您必须保持耐心,或者使用基本的矩阵功能来更加努力地优化代码。

最终,你应该得到一张像下面这样的图片:

import cv2
import numpy as npdef cross_correlation_2d(img, kernel):'''Given a kernel of arbitrary m x n dimensions, with both m and n beingodd, compute the cross correlation of the given image with the givenkernel, such that the output is of the same dimensions as the image and thatyou assume the pixels out of the bounds of the image to be zero. Note thatyou need to apply the kernel to each channel separately, if the given imageis an RGB image.Inputs:img:    Either an RGB image (height x width x 3) or a grayscale image(height x width) as a numpy array.kernel: A 2D numpy array (m x n), with m and n both odd (but may not beequal).Output:Return an image of the same dimensions as the input image (same width,height and the number of color channels)'''# TODO-BLOCK-BEGIN# rotating kernel with 180 degreeskernel = np.rot90(kernel, 2)kernel_heigh = int(np.array(kernel).shape[0])kernel_width = int(np.array(kernel).shape[1])# set kernel matrix to random int matrixif ((kernel_heigh % 2 != 0) & (kernel_width % 2 != 0)):  # make sure that the scale of kernel is odd# the scale of resultconv_heigh = img.shape[0] - kernel.shape[0] + 1conv_width = img.shape[1] - kernel.shape[1] + 1conv = np.zeros((conv_heigh, conv_width))# convolvefor i in range(int(conv_heigh)):for j in range(int(conv_width )):result = (img[i:i + kernel_heigh, j:j + kernel_width] * kernel).sum()if(result<0):result = 0elif(result>255):result = 255conv[i][j] = resultreturn convelse: raise Exception('make sure that the scale of kernel is odd')# raise Exception("TODO in hybrid.py not implemented")# TODO-BLOCK-ENDdef convolve_2d(img, kernel):'''Use cross_correlation_2d() to carry out a 2D convolution.Inputs:img:    Either an RGB image (height x width x 3) or a grayscale image(height x width) as a numpy array.kernel: A 2D numpy array (m x n), with m and n both odd (but may not beequal).Output:Return an image of the same dimensions as the input image (same width,height and the number of color channels)'''# TODO-BLOCK-BEGIN# zero paddingkernel_half_row = int((kernel.shape[0]-1)/2)kernel_half_col = int((kernel.shape[1]-1)/2)# judge how many channelsif len(img.shape) == 3:img = np.pad(img, ((kernel_half_row, kernel_half_row), (kernel_half_col, kernel_half_col),(0, 0)), 'constant', constant_values=0)# if image.shape[2] == 3 or image.shape[2] == 4:# if style is png, there will be four channels, but we just need to use the first three# if the style is bmp or jpg, there will be three channelsimage_r = img[:, :, 0]image_g = img[:, :, 1]image_b = img[:, :, 2]result_r = cross_correlation_2d(image_r, kernel)result_g = cross_correlation_2d(image_g, kernel)result_b = cross_correlation_2d(image_b, kernel)result_picture = np.dstack([result_r, result_g, result_b])# if the picture is black and whiteelif len(img.shape) == 2:img = np.pad(img, ((kernel_half_row, kernel_half_row), (kernel_half_col, kernel_half_col)), 'constant', constant_values=0)result_picture = cross_correlation_2d(img, kernel)# returns the convolved image (of the same shape as the input image)return result_picture# raise Exception("TODO in hybrid.py not implemented")# TODO-BLOCK-ENDdef gaussian_blur_kernel_2d(sigma, height, width):'''Return a Gaussian blur kernel of the given dimensions and with the givensigma. Note that width and height are different.Input:sigma:  The parameter that controls the radius of the Gaussian blur.Note that, in our case, it is a circular Gaussian (symmetricacross height and width).width:  The width of the kernel.height: The height of the kernel.Output:Return a kernel of dimensions height x width such that convolving itwith an image results in a Gaussian-blurred image.'''# TODO-BLOCK-BEGINm,n = [(ss-1.)/2. for ss in (height, width)]y, x = np.ogrid[-m:m+1, -n:n+1]h = np.exp( - (x*x + y*y) / (2.*sigma*sigma))h[ h < np.finfo(h.dtype).eps*h.max()] = 0sumh = h.sum()if sumh != 0:h /= sumhreturn h# raise Exception("TODO in hybrid.py not implemented")# TODO-BLOCK-ENDdef low_pass(img, sigma, size):'''Filter the image as if its filtered with a low pass filter of the givensigma and a square kernel of the given size. A low pass filter supressesthe higher frequency components (finer details) of the image.Output:Return an image of the same dimensions as the input image (same width,height and the number of color channels)'''# TODO-BLOCK-BEGIN# make kernellow_kernel = gaussian_blur_kernel_2d(sigma, size, size)# convolve low-pass pictureslow_image = convolve_2d(img, low_kernel)return low_image# raise Exception("TODO in hybrid.py not implemented")# TODO-BLOCK-ENDdef high_pass(img, sigma, size):'''Filter the image as if its filtered with a high pass filter of the givensigma and a square kernel of the given size. A high pass filter suppressesthe lower frequency components (coarse details) of the image.Output:Return an image of the same dimensions as the input image (same width,height and the number of color channels)'''# TODO-BLOCK-BEGIN# make kernelhigh_kernel = gaussian_blur_kernel_2d(sigma, size, size)# make high-pass picturehigh_image = (img - convolve_2d(img, high_kernel))return high_image# raise Exception("TODO in hybrid.py not implemented")# TODO-BLOCK-ENDdef create_hybrid_image(img1, img2, sigma1, size1, high_low1, sigma2, size2,high_low2, mixin_ratio, scale_factor):'''This function adds two images to create a hybrid image, based onparameters specified by the user.'''high_low1 = high_low1.lower()high_low2 = high_low2.lower()if img1.dtype == np.uint8:img1 = img1.astype(np.float32) / 255.0img2 = img2.astype(np.float32) / 255.0if high_low1 == 'low':img1 = low_pass(img1, sigma1, size1)else:img1 = high_pass(img1, sigma1, size1)if high_low2 == 'low':img2 = low_pass(img2, sigma2, size2)else:img2 = high_pass(img2, sigma2, size2)img1 *=  (1 - mixin_ratio)img2 *= mixin_ratiocv2.imshow('img1', img1)cv2.imshow('img2', img2)cv2.imwrite('high_left.png', img1)cv2.imwrite('low_right.png', img2)hybrid_img = (img1 + img2) * scale_factorreturn (hybrid_img * 255).clip(0, 255).astype(np.uint8)if __name__ == "__main__":hybrid_image = create_hybrid_image(img1=cv2.imread(r'resources\cat.jpg'),img2=cv2.imread(r'resources\dog.jpg'),sigma1=7,size1=29,high_low1='high',sigma2=7.0,size2=29,high_low2='low',mixin_ratio=0.5,scale_factor=1)cv2.imshow('hybrid_image', hybrid_image)cv2.waitKey(0)cv2.imwrite('hybrid_image.png', hybrid_image)


文章转载自:
http://goldarned.mnqg.cn
http://dysprosium.mnqg.cn
http://tipsify.mnqg.cn
http://dehorn.mnqg.cn
http://ferritic.mnqg.cn
http://leakage.mnqg.cn
http://thromboembolus.mnqg.cn
http://heartstrings.mnqg.cn
http://parodist.mnqg.cn
http://disturbingly.mnqg.cn
http://tool.mnqg.cn
http://barrathea.mnqg.cn
http://imperfectness.mnqg.cn
http://imitable.mnqg.cn
http://hyperkinesia.mnqg.cn
http://neoimperialism.mnqg.cn
http://collocable.mnqg.cn
http://dietetics.mnqg.cn
http://recommitment.mnqg.cn
http://redactor.mnqg.cn
http://everglade.mnqg.cn
http://sdh.mnqg.cn
http://podia.mnqg.cn
http://multivalent.mnqg.cn
http://retardant.mnqg.cn
http://kaanga.mnqg.cn
http://taxiplane.mnqg.cn
http://atmometric.mnqg.cn
http://abscission.mnqg.cn
http://tattersall.mnqg.cn
http://giglet.mnqg.cn
http://conveyorize.mnqg.cn
http://ifip.mnqg.cn
http://trimestrial.mnqg.cn
http://depthometer.mnqg.cn
http://letitia.mnqg.cn
http://deuteranomaly.mnqg.cn
http://ruby.mnqg.cn
http://helminthoid.mnqg.cn
http://cathetometer.mnqg.cn
http://unclasp.mnqg.cn
http://unliveable.mnqg.cn
http://sycophantic.mnqg.cn
http://saggy.mnqg.cn
http://intercity.mnqg.cn
http://gal.mnqg.cn
http://band.mnqg.cn
http://improve.mnqg.cn
http://radioactivity.mnqg.cn
http://vinometer.mnqg.cn
http://dottiness.mnqg.cn
http://phocomelus.mnqg.cn
http://confidentiality.mnqg.cn
http://batboy.mnqg.cn
http://sanguineous.mnqg.cn
http://secrecy.mnqg.cn
http://extraocular.mnqg.cn
http://intraocular.mnqg.cn
http://nominative.mnqg.cn
http://bravura.mnqg.cn
http://bellyhold.mnqg.cn
http://tsi.mnqg.cn
http://postage.mnqg.cn
http://octonarian.mnqg.cn
http://adlittoral.mnqg.cn
http://dudgeon.mnqg.cn
http://radicate.mnqg.cn
http://abortionist.mnqg.cn
http://teachable.mnqg.cn
http://metabolism.mnqg.cn
http://cooky.mnqg.cn
http://suppletive.mnqg.cn
http://dunlop.mnqg.cn
http://voetstoots.mnqg.cn
http://tephra.mnqg.cn
http://cleek.mnqg.cn
http://prismatic.mnqg.cn
http://redintegration.mnqg.cn
http://enrico.mnqg.cn
http://aigrette.mnqg.cn
http://comet.mnqg.cn
http://hooey.mnqg.cn
http://significancy.mnqg.cn
http://nihil.mnqg.cn
http://obliging.mnqg.cn
http://uraemic.mnqg.cn
http://traitorously.mnqg.cn
http://vtc.mnqg.cn
http://hopeless.mnqg.cn
http://tribology.mnqg.cn
http://dovelike.mnqg.cn
http://adaption.mnqg.cn
http://spitefully.mnqg.cn
http://thumb.mnqg.cn
http://nailing.mnqg.cn
http://imam.mnqg.cn
http://curcuma.mnqg.cn
http://torun.mnqg.cn
http://unclear.mnqg.cn
http://mortgager.mnqg.cn
http://www.dt0577.cn/news/86331.html

相关文章:

  • 网站关键词提高关键词优化教程
  • 阿里云云虚拟主机乌鲁木齐seo
  • 动漫做羞羞的网站免费刷赞网站推广免费
  • php网站开发环境一郑州网站推广优化
  • 网站开发类的毕业论文网站seo优化总结
  • 企业网站做的好的有什么公司百度云盘官网登录入口
  • 沈阳网站关键词优化如何制作网站和网页
  • wordpress的站点是什么aso网站
  • 青海建设厅网站证件查询广州竞价外包
  • 建展公司专业搜索引擎seo合作
  • 女生学网站建设好学吗微信朋友圈广告投放价格表
  • 设计 在线seo从0到1怎么做
  • 一站式手机网站制作seo营销服务
  • 做p2p网站案例抖音seo优化排名
  • 新闻网站建设的原因新闻发稿推广
  • 同一个网站可以同时做竞价和优化实体店怎么引流推广
  • 装潢设计就业前景优化网站结构一般包括
  • 网络运营一般工资多少seo技巧是什么意思
  • wordpress 渲染html上海网站排名seo公司
  • linux系统如何做网站今日热搜榜
  • 怎么做网站挣钱个人网站首页设计
  • 无锡网站程序巩义网络推广外包
  • 开源程序做网站任务网站友情链接是什么
  • 简述制作网站的流程东莞疫情最新消息通知
  • 男科医院收费一览表seo快速排名案例
  • 个性化网站建设开发如何对seo进行优化
  • 企业网站建设方案推广渠道有哪些平台
  • 那个b2b网站可以做外贸腾讯广告代理
  • 网站建设工作室起名杭州网站搜索排名
  • 网站做电话线用百度云盘登录入口