让图像随机缩放进行数据增强_缩放和增强终于来了

让图像随机缩放进行数据增强

We all know the scene. Two detectives on a cop show stand in a dimly lit room filled with monitors, reviewing surveillance images. A tech guy (yes, it’s almost always a guy) queues up image after image as the detectives look on, squinting at the screen in concentration. “There’s nothing here!” one detective insists. They’re about to give up, when the other detective (our hero) shouts, “Wait!”

我们都知道现场。 警察表演中的两名侦探站在昏暗的房间里,房间里装满监视器,查看监视图像。 当侦探望着镜头时,一个技术人员(是的,几乎总是一个人)在一个接一个的图像中排队,凝视着屏幕。 “这里什么都没有!” 一名侦探坚持。 当另一名侦探(我们的英雄)大喊:“等等!”时,他们将放弃。

Everyone stops. “Zoom in there!” the detective says. The tech guy obligingly zooms in on a grainy corner of the image. “Enhance that!” the detective intones. The tech guy taps some keys, mutters something about algorithms, and suddenly the image comes into focus, revealing some tiny, significant detail. The case is cracked wide open!

大家停下来 “放大那里!” T他的侦探说。 技术人员会努力放大图像的颗粒状角落。 “增强!” 侦探声调。 技术人员轻按一些键,喃喃自语一些算法,然后图像立即成为焦点,揭示了一些微小的重要细节。 案子开得裂了!

This scene is a crime drama cliché so pervasive that it has inspired its own meme video with nearly a million views.

这个场景是一个犯罪戏剧陈词滥调,它无处不在,以近百万的观看次数启发了自己的模因视频

Scenes like these drive real tech people bananas, because “zoom and enhance” has always seemed like an impossible fantasy. Until now. Thanks to two recent innovations, zoom and enhance is finally here. It has the potential to radically change police surveillance, often in concerning ways — or at least help you bring back your photos from the early ’00s.

诸如此类的场景推动了真正的技术人员的成长,因为“ 缩放和增强 ”一直看起来像是不可能的幻想。 到现在。 多亏了最近的两项创新,缩放和增强终于到了。 它有可能从根本上改变警察的监视方式,通常以令人关注的方式进行,或者至少可以帮助您恢复20年代初期的照片。

The first innovation behind real-life zoom and enhance comes from the world of photography. Until recently, photographers had two primary options for digital cameras: professional DSLRs like the Nikon D series, or cheap compact consumer cameras, like the kind you’d use for birthday or travel snapshots. DSLRs take great photos, but they’re bulky and conspicuous and can be hard to operate — not a great combo for surveillance work. Compact cameras rarely have the quality necessary for surveillance professionals.

现实生活中缩放和增强背后的第一个创新来自摄影界。 直到最近,摄影师还为数码相机提供了两个主要选择: 尼康D系列等专业数码单反相机,或者像您用于生日或旅行快照的廉价紧凑型家用相机。 DSLR可以拍摄出色的照片,但它们体积庞大且引人注目,并且难以操作-并不是监视工作的绝佳组合 。 紧凑型摄像机很少具有监视专业人员所需的质量。

That all began to change around 2015, with the rise of mirrorless cameras. These cameras have the tiny form factor of a compact camera, but thanks to advances in imaging chips driven in part by smartphones, they pack in the same high-quality image sensors usually found in a DSLR. Increasingly, they also borrow complex image processing software from the smartphone world, further enhancing their capabilities. And crucially, they allow for the use of professional lenses — easily the most important factor for taking high-quality photos.

随着无反光镜相机的兴起,这一切在2015年左右开始改变。 这些相机的外形比紧凑型相机小,但是由于部分由智能手机驱动的成像芯片的进步,它们采用了通常与DSLR相同的高质量图像传感器。 他们也越来越多地从智能手机领域借用复杂的图像处理软件 ,从而进一步增强了功能。 至关重要的是,它们允许使用专业镜头-轻松成为拍摄高质量照片的最重要因素

For a few thousand dollars, a surveillance professional or police force can now purchase tiny, easy-to-use cameras that take better photos than the best professional cameras from just a few years ago.

监视专业人员或警察部队现在只需花几千美元,就可以购买微型,易于使用的相机,这些相机比几年前最好的专业相机拍摄的照片更好。

The end result is a tiny camera that you can carry and use inconspicuously, while taking extremely detailed, high-resolution photos. The Q, a mirrorless camera from legendary German camera maker Leica, largely kicked off the trend. The latest Q model weighs just 1.4 pounds and takes 47-megapixel photos through an obscenely crisp lens that sees more detail than the human eye. With an ISO rating of 50,000 (15 times higher than that achieved by the fastest analog films), it can also essentially see in the dark.

最终结果是一个微型相机,您可以毫

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个使用PyTorch和Python来打开指定文件夹,并对文件夹中的图像数据进行随机翻转、旋转、随机平移和缩放的完整代码示例: ```python import os import random from PIL import Image import torchvision.transforms as transforms # 指定文件夹路径 folder_path = "your_folder_path" # 定义数据增强的transform transform = transforms.Compose([ transforms.RandomHorizontalFlip(), transforms.RandomVerticalFlip(), transforms.RandomRotation(degrees=30), transforms.RandomAffine(degrees=0, translate=(0.1, 0.1), scale=(0.8, 1.2)), ]) # 遍历文件夹中的所有图像文件 for file_name in os.listdir(folder_path): file_path = os.path.join(folder_path, file_name) # 读取图像 image = Image.open(file_path) # 应用数据增强 augmented_image = transform(image) # 保存增强后的图像 augmented_file_path = os.path.join(folder_path, "augmented_" + file_name) augmented_image.save(augmented_file_path) ``` 在上述代码中,你需要将`your_folder_path`替换为你要处理的文件夹的路径。然后,使用`transforms.Compose`将多个数据增强操作组合成一个transform对象。接下来,使用`os.listdir`遍历文件夹中的所有图像文件,并使用`Image.open`打开每个图像文件。然后,将图像应用数据增强操作,通过`save()`保存增强后的图像到同一文件夹下,并添加前缀"augmented_"以示区分。 请确保你已经安装了PyTorch和Pillow库(可以通过`pip install torch torchvision Pillow`进行安装)。此外,你还可以根据需要调整数据增强操作的参数,如翻转、旋转的角度、平移和缩放的范围等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值