我正在尝试通过自己做一些事来学习OpenCV.在这种特殊情况下,我想拍摄灰度图像的位平面.代码似乎有效,但它只适用于第7位和第6位,而不是其余6位,因为它只显示约1/3图像的良好结果.我还没有发现它有什么问题.我非常感谢有关此问题的一些帮助,因为我只是在编写我的第一个代码库.
这是我得到的第一位:
这是第7位:
这是我的代码:
#include <opencv2\opencv.hpp>
#include <math.h>
using namespace cv;
using namespace std;
int main( int argc, char** argv ) {
Mat m1 = imread("grayscalerose.jpg");
imshow("Original",m1);
int cols, rows, x, y;
cols = m1.cols;
rows = m1.rows;
printf("%d %d \n",m1.rows,m1.cols);
Mat out1(rows, cols, CV_8UC1, Scalar(0));
out1 = (m1/128); //Here's where I divide by either 1,2,4,8,16,32,64, or 128 to get the corresponding bit planes
for (int y = 0; y < rows; y++){
for (int x = 0; x < …
Run Code Online (Sandbox Code Playgroud)