读二进制图像数据 [英] Reading Binary Image Data

查看:98
本文介绍了读二进制图像数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计。

我正在寻找有关如何阅读二进制图像数据的一些信息。基本上RAW图像文件是比特串,每个像素具有2个字节。我需要做的是依次读取每个像素的值,然后存储在另一个变量px1,pix2等中。我正在一次运行2个像素的迭代算法,然后移动到接下来的两个像素。

我在阅读数据时遇到了很多问题。从网和各种书籍我看到readline方法然而这寻找新的线路charicters。我需要能从文件中读取一定数量位的值。


例如读取第一个16位长的像素数据我需要的东西只能读取那些16位并返回其值。

谢谢。

Ed

Hey Guys.
I''m looking for some info on how to read binary image data. Basicly RAW image files are strings of bits with say 2 bytes per pixel. What i need to do is read the value of each pixel in turn and store then in another variable, px1, pix2 etc. I''m running an iterative algorithm on 2 pixels at a time then moving to the next two pixels.
I am having alot of problems however reading the data. from the net and various books i see the readline method however this looks for new line charicters. I need something that will read the value of a certain number of bits from the file.

for example to read the first pixel data which is 16bits long i need something that will just read those 16bits and return its value.
Thanks.
Ed

推荐答案

这将一次读取两个字节:
This will read two bytes at a time:
展开 | 选择 | Wrap | 行号



这将一次读取两个字节:
This will read two bytes at a time:
展开 | 选择 | 换行 | 行号



Hey Guys。

我正在寻找有关如何读取二进制图像数据的一些信息。基本上RAW图像文件是比特串,每个像素具有2个字节。我需要做的是依次读取每个像素的值,然后存储在另一个变量px1,pix2等中。我正在一次运行2个像素的迭代算法,然后移动到接下来的两个像素。

我在阅读数据时遇到了很多问题。从网和各种书籍我看到readline方法然而这寻找新的线路charicters。我需要能从文件中读取一定数量位的值。


例如读取第一个16位长的像素数据我需要的东西只能读取那些16位并返回其值。

谢谢。

Ed
Hey Guys.
I''m looking for some info on how to read binary image data. Basicly RAW image files are strings of bits with say 2 bytes per pixel. What i need to do is read the value of each pixel in turn and store then in another variable, px1, pix2 etc. I''m running an iterative algorithm on 2 pixels at a time then moving to the next two pixels.
I am having alot of problems however reading the data. from the net and various books i see the readline method however this looks for new line charicters. I need something that will read the value of a certain number of bits from the file.

for example to read the first pixel data which is 16bits long i need something that will just read those 16bits and return its value.
Thanks.
Ed



我猜你知道您正在处理的图像格式的内部工作方式,可以将格式信息(标题)与图像的实际像素(数据)分开。


对于处理大型数据集, SciPy 数组具有本机python列表缺少的一些功能。

I''m guessing that you know the inner workings of the image format that you are working on and can separate the format information (header) from the actual pixels of the image (data).

For working on large data sets, SciPy arrays have some features that native python lists lack.


这篇关于读二进制图像数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆