# Extract data from the Images

**URL:** <https://forum.opencv.org/t/extract-data-from-the-images/10300>\
**Category:** C++\
**Tags:** programming\
**Created:** [September 24, 2022, 6:48am UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300 "2022-09-24T06:48:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocvfasc](https://avatars.discourse-cdn.com/v4/letter/o/eb8c5e/32.png) [@ocvfasc](https://forum.opencv.org/u/ocvfasc)\
**Post date:** [September 24, 2022, 6:48am UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/1 "2022-09-24T06:48:25Z")

</div>

Hello,

Could you let me know if there is a possibility to extract the data of each bmp/jpg image file, I need this data to perform the CRC (cyclic redundancy check) for each image file.

---

<div class="post-metadata">

**Author:** ![matti.vuori](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@matti.vuori](https://forum.opencv.org/u/matti.vuori)\
**Post date:** [September 24, 2022, 7:21am UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/2 "2022-09-24T07:21:29Z")

</div>

For a CRC checksum of a file, the file is the data…  
Alternatively: imread()

---

<div class="post-metadata">

**Author:** ![ocvfasc](https://avatars.discourse-cdn.com/v4/letter/o/eb8c5e/32.png) [@ocvfasc](https://forum.opencv.org/u/ocvfasc)\
**Post date:** [September 24, 2022, 8:35am UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/3 "2022-09-24T08:35:48Z")

</div>

Thanks for the reply!  
I am aware that file is the data, I need data in Hexadecimal to calculate the CRC.  
Could you please guide me to convert this file data into the Hex?

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [September 24, 2022, 10:03am UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/4 "2022-09-24T10:03:24Z")

</div>

> [@ocvfasc](#):
>
> I need data in Hexadecimal to calculate the CRC.

no, you dont. (why do you think so ?)

just read one byte after the other, and pass it to your crc

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [September 24, 2022, 12:24pm UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/5 "2022-09-24T12:24:04Z")

</div>

what you’re saying sounds like you don’t understand what hexadecimal is, what bits and bytes are, what a file is, what a CRC is, or why you’re even trying to do any of that.

this has nothing to do with OpenCV. please find an appropriate forum… but before you do that, you should _learn_ about these things. don’t ask questions for which you can trivially get answers from existing materials (books etc)

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [September 25, 2022, 2:20pm UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/6 "2022-09-25T14:20:54Z")

</div>

also, what kind of crc are you trying to use ? please show !

if you really need to work on the uncompressed pixels, it would be a easy:

```
Mat img = imread("my.bmp", IMREAD_UNCHANGED);
uchar *pixels = img.ptr();
size_t n = img.total();

```

---

<div class="post-metadata">

**Author:** ![ocvfasc](https://avatars.discourse-cdn.com/v4/letter/o/eb8c5e/32.png) [@ocvfasc](https://forum.opencv.org/u/ocvfasc)\
**Post date:** [September 27, 2022, 12:15pm UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/7 "2022-09-27T12:15:34Z")

</div>

Autosar 8-bit polynomial CRC.  
Could you share me a example on reading byte by byte from imread()

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [September 27, 2022, 12:49pm UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/8 "2022-09-27T12:49:40Z")

</div>

sure: [OpenCV: Mat - The Basic Image Container](https://docs.opencv.org/4.x/d6/d6d/tutorial_mat_the_basic_image_container.html)

---

<div class="post-metadata">

**Author:** ![ocvfasc](https://avatars.discourse-cdn.com/v4/letter/o/eb8c5e/32.png) [@ocvfasc](https://forum.opencv.org/u/ocvfasc)\
**Post date:** [September 27, 2022, 2:39pm UTC](https://forum.opencv.org/t/extract-data-from-the-images/10300/9 "2022-09-27T14:39:52Z")

</div>

That was so useful, Thanks a lot!
