将RGB图像转换为8位RGB图像

12次浏览(过去30天)
Sajid Afaque
Sajid Afaque 2022年10月10日
评论道: Sajid Afaque 2022年10月11日
你好,
我有一个RGB图像(示例包含- imfinfo建议其24位图像)
现在我需要将其转换为8位RGB图像。
我该怎么做呢?
当我在谷歌上搜索这个问题时,我知道要减少比特,我必须除以256,但当我使用“imread”时,像素被分为3个单独的(R,G和B)
2的评论
Sajid Afaque
Sajid Afaque 2022年10月10日
编辑:Sajid Afaque 2022年10月10日
是的,
忘记我附上的图像,
现在想象我有一个16位RGB图像,我如何将它转换为8位RGB图像?(每像素8位)

登录评论。

接受的答案

Chunru
Chunru 2022年10月10日
编辑:Chunru 2022年10月10日
Im = imread(“//www.ru-cchi.com/matlabcentral/answers/uploaded_files/1150855/my_image.jpg”);
[x,cmap] = rgb2ind(im,256);
imwrite (x,提出,“new_im.tif”)
imfinfo (“new_im.tif”)
ans =带字段的结构:
文件名:'/users/mss.system. sxxssm / new_imt .tif' FileModDate: '10- 10- 2022 08:44:00'文件大小:28789400格式:'tif' FormatVersion:[]宽度:6485高度:4913位深度:8 ColorType: 'indexed' FormatSignature: [73 73 42 0] ByteOrder: 'little-endian' NewSubFileType: 0 BitsPerSample: 8压缩:'PackBits' PhotometricInterpretation: 'RGB Palette' StripOffsets:[8 448141 898960 1356409 1819783 2271388 2721773 3170526 3613626 4052208 4491269 49294482 5810260 6255633 6694416 7129850 7571051 8012049 8455557 8890185 9321557 9744499 10164448 10585440 11026774 11476633…]SamplesPerPixel: 1 RowsPerStrip: 76 StripByteCounts:[448133 450819 457449 463374 451605 450385 448753 438582 439061 438249 434964 445778 445373 438734 434634 440998 443508 434628 431372 422942 419949 420992 441334 449859 437577 438804 450355 457902…]XResolution: 72 YResolution: 72 resoltionunit: 'Inch' Colormap: [256×3 double] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] tileoffset: [] TileByteCounts: [] Orientation: 1 FillOrder: 1 GrayResponseUnit: 0.0100 MaxSampleValue: 255 MinSampleValue:0阈值:1偏移量:28787142
dir
, . .new_im.tif
3评论
Sajid Afaque
Sajid Afaque 2022年10月11日
谢谢 @Chunru
如果可能的话,请解释一下我如何从分析上看到从24位到8位的转换。
下面这行代码到底发生了什么
[x,cmap] = rgb2ind(im,256);

登录评论。

更多答案(0)

类别

了解更多转换图像类型帮助中心而且文件交换

2022世界杯八强谁会赢?


释放

R2020b

世界杯预选赛小组名单社区寻宝

在MATLAB Central中找到宝藏,并发现社区如何帮助您!世界杯预选赛小组名单

开始狩猎!

翻译的

Baidu
map