hi please help, c++ windows form code text box

Hesham AbdMalek Ramadan 1 Reputation point
2021-12-14T15:25:25.97+00:00

hi i have a code like this

cout << "pixels intensities = \n" << image1 << endl;
cout << "image rows=" << image1.rows << endl;
cout << "image cols=" << image1.cols << endl;
cout << "image pixel total=" << image1.total() << endl;
cout << "image channels=" << image1.channels() << endl;
cout << "image pixel depth=" << image1.depth() << endl;
//return a number from 0 to 6
int pixel_v = image1.at<uchar>(0, 0);
int max = 0, min = 255, sum = 0;
for (int i = 0; i < image1.rows; i++)
{
for (int j = 0; j < image1.cols; j++)
{
sum = sum + image1.at<uchar>(i, j);
if (image1.at<uchar>(i, j) > max)
{
max = image1.at<uchar>(i, j);
}
if (image1.at<uchar>(i, j) < min)
{
min = image1.at<uchar>(i, j);
}
}
}
float avg = sum / image1.total();
cout << "max_value=" << max << endl;
cout << "min_value=" << min << endl;
cout << "avg=" << avg << endl;

need to show the output it in a text box

Developer technologies C++
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.5K Reputation points
    2021-12-14T16:18:35.607+00:00

    Check this technique:

    #include <sstream>
    
    . . .
    
    using namespace std;
    stringstream cout;
    const char* endl = "\r\n";
    
    // Your current code that uses 'cout':
    
    cout << "pixels intensities =" << image1 << endl;
    cout << "image rows=" << image1.rows << endl;
    . . . etc.
    
    textBox1->Text = gcnew String( cout.str( ).c_str( ) );
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.