开发者

Reading a black-and-white image as 0's and 1's [closed]

开发者 https://www.devze.com 2023-02-19 05:21 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

How can I read a black-and-white image file as ones and zeros? I'm using VC++6, OpenCv, and the FANN (Faster Artificial Ne开发者_Go百科ural Network) Library.


The pixel data in an image file is represented in a format. There are may different methods for organizing pixel data in a file: TIFF, JPEG, GIF, PNG, BMP, etc., just to name a few. Need more information about your file before detailed help can be given.

All data in a file is made of ones and zeros, just the nature of the computer world. Perhaps if you indicate what you are doing with the image data, more information can be presented.

See the following:

  1. Wikipedia page on image formats.
  2. std::ifstream::open, binary mode.
  3. std::ifstream::read
  4. std::vector to hold the data.
  5. Search Stack Overflow for the keywords "read binary file".


Open the file. Read each pixel's color value, and interpret a white pixel as a 1 and a black pixel as a 0.

If you expect me to write this program for you, I bill out at $250 US per hour.

0

精彩评论

暂无评论...
验证码 换一张
取 消