Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can data from Mat convert to bitset?

I have a binary mat array 20 x 20. I'm doing specific pixel line scanning example at Mat[1][10]. This array will consist a string of example, 11111000000000000000. This string will go through the bitset operation which is to #include <bitset>.

How can i manage to do read the string line from the mat array and complete the bitset operation?

i can read the pixel by pixel using this.

for(int x=0;x< frame_gray.cols;x+=1){
for (int y=0; y< frame_gray.rows; y+=1){
if (frame_gray.at<uchar>(y,x)==0)
{ cnt++; cout << "0 binary=" << cnt << endl;}
else
{  cnt++;cout << "1 binary=" << cnt << endl;width++;}
//waitKey(0);

}

After few question in the forum, i can read the line array but still failed to get the bitset operation to be completed. This is the bitset operation suggested by the team member in this forum. BUt how can i do this?

#include <bitset>
bitset<24> a("00001111100000111100000");
// 000001111100000111100000
auto b = a >> 1;
// 000000111110000011110000
auto c = a ^ b;
// 000001000010000100010000
auto len = c.count();  // popcnt() , if you use integers.
// 4

Can data from Mat convert to bitset?

image description I have a binary mat array 20 x 20. I'm doing specific pixel line scanning example at Mat[1][10]. This array will consist a string of example, 11111000000000000000. This string will go through the bitset operation which is to #include <bitset>.

i sample the scan to look on the bit transition on the lane across the image. Because i should have a pattern o this process.

How can i manage to do read the string line from the mat array and complete the bitset operation?

i can read the pixel by pixel using this.

for(int x=0;x< frame_gray.cols;x+=1){
for (int y=0; y< frame_gray.rows; y+=1){
if (frame_gray.at<uchar>(y,x)==0)
{ cnt++; cout << "0 binary=" << cnt << endl;}
else
{  cnt++;cout << "1 binary=" << cnt << endl;width++;}
//waitKey(0);

}

After few question in the forum, i can read the line array but still failed to get the bitset operation to be completed. This is the bitset operation suggested by the team member in this forum. BUt how can i do this?

#include <bitset>
bitset<24> a("00001111100000111100000");
// 000001111100000111100000
auto b = a >> 1;
// 000000111110000011110000
auto c = a ^ b;
// 000001000010000100010000
auto len = c.count();  // popcnt() , if you use integers.
// 4