Matlab下降低图像质量
问候, 我正在尝试找到一种简单的方法来处理图像,以便将其质量从 8 位降低到 3 位。
实现这一目标的最简单方法是什么? 干杯
Greetings,
I am trying to find an easy way to manipulate an image so that I can decrease the quality of it from 8bit to 3bit.
What would be the easiest way to achieve this?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果要线性缩放,只需将每个像素值除以255/7即可(即如果原始图像存储在矩阵I中,则让低分辨率图像J = I/(255/7))。
更新:由于我的缩放常数错误。
这是一个示例:
If you want to linearly scale it, just divide each pixel value by 255/7 (i.e. if the original image is stored in a matrix I, let the low-res image J = I/(255/7)).
UPDATED: Due to a mistake in my scaling constant.
Here's an example:
如果您有一个在 MATLAB 中存储为
uint8
类型的图像,则像素值的范围将从 0 到 255。将值限制为仅 3 位精度(因此仅使用数字 0到 7),您可以按以下示例缩放数据:请注意,即使缩放值限制在 0 到 7 的范围内,存储它们的变量仍然是
uint8
数据类型,因为这是 MATLAB 所能做到的最小的。未使用的较高位只是 0。根据将缩放的图像数据输出到文件的方式(如果您想这样做),您也许能够将存储值的精度降低到小于 8 位(例如, PNG 文件可以存储 4 位类型)。
If you have an image that is stored as a
uint8
type in MATLAB, then the pixel values will range from 0 to 255. To limit the values to only 3 bits of precision (thus using only the numbers 0 to 7), you can scale the data as in the following example:Note that even though the scaled values are limited to the range of 0 to 7, the variable storing them is still a
uint8
data type since this is the smallest MATLAB will go. The unused higher bits are simply 0.Depending on how you output the scaled image data to a file (if you want to do that), you may be able to reduce the precision of the stored values to less than 8 bits (for example, PNG files can store 4-bit types).
int8
是 Matlab 中最小的整数值。通过右移图像中任何像素的任何值,您只能使用 int8 中 8 位中的 3 位。如果您可以访问 Fixed-Point Toolbox,则可以使用带有简单符号的
numerictype
对象:Cit。来自Matlab手册:
int8
is the smallest integer value in Matlab. You could use only 3 out of 8 bits in int8 by shifting to right any value of any pixel in image.If you have access to Fixed-Point Toolbox instead, you can use
numerictype
objects with the simple notation:Cit. from Matlab's manual: