Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Please comment about speed and memory optimization for my code. It is about converting a 10 bit raw image (bayer pattern) from int** and displaying some lines.

void AutomaticMacbethDetection::DrawMacbethROI(ColorCheckerBatchRGB ColorCheckerBatchRGB, int ** raw_frame,int _width, int _height)
{
    //Mat(int rows, int cols, int type);
    cv::Mat src(_height,_width,CV_32F);
    std::vector<float> channel;
    for (int w = 0; w < _width; w++)
    {               
        for (int h = 0; h < _height; h++)
        {
            float temp =raw_frame[h][w];    
            channel.push_back(temp);
            src.at<float>(h,w) = temp;
        }               
    }   

    float divider = Utilities::tprctile(channel,99.2);
    src = src/divider;

    /*ofstream myfile;
    myfile.open("C:\\Users\\gdarmon\\Desktop\\OpenCV_CR.txt");  
    myfile << src;*/


    for (int w = 0; w < 4; w++)
    {
        for (int h = 0; h < 6; h++)
        {
            for (int i = 0; i < 4; i++)
            {
                int x1 = ColorCheckerBatchRGB.m_batchIndsX[i][w][h];
                int y1 = ColorCheckerBatchRGB.m_batchIndsY[i][w][h];
                int x2 = ColorCheckerBatchRGB.m_batchIndsX[i+1][w][h];
                int y2 = ColorCheckerBatchRGB.m_batchIndsY[i+1][w][h];
                cv::line(src,cv::Point(x1,y1),cv::Point(x2,y2),cv::Scalar(255,240,50),4);
            }
        }
    }

    cv::resize(src,src,cv::Size(),0.3,0.3,cv::INTER_LINEAR);
    cv::imshow("detected", src);    
    cv::waitKey(0);

}
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.