@ -11,17 +11,15 @@ In this tutorial you will learn how to:
.. container :: enumeratevisibleitemswithsquare
+ Access pixel values
+ Initialize a matrix with zeros
+ Learn what :saturate_cast:`saturate_cast <>` does and why it is useful
+ Get some cool info about pixel transformations
Theory
=======
.. note ::
The explanation below belongs to the book `Computer Vision: Algorithms and Applications <http://szeliski.org/Book/> `_ by Richard Szeliski
Image Processing
@ -38,7 +36,7 @@ Image Processing
Pixel Transforms
^^^^^^^^^^^^^^^^^
-----------------
.. container :: enumeratevisibleitemswithsquare
@ -47,7 +45,7 @@ Pixel Transforms
* Examples of such operators include * brightness and contrast adjustments* as well as color correction and transformations.
Brightness and contrast adjustments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------------
.. container :: enumeratevisibleitemswithsquare
@ -70,8 +68,6 @@ Brightness and contrast adjustments
Code
=====
.. container :: enumeratevisibleitemswithsquare
* The following code performs the operation :math: `g(i,j) = \alpha \cdot f(i,j) + \beta` :
.. code-block :: cpp
@ -98,10 +94,9 @@ Code
std::cout<<"* Enter the beta value [0-100]: "; std::cin>>beta;
/// Do the operation new_image(i,j) = alpha*image(i,j) + beta
for( int y = 0; y < image.rows; y++ )
{ for( int x = 0; x < image.cols; x++ )
{ for( int c = 0; c < 3; c++ )
{
for( int y = 0; y < image.rows; y++ ) {
for( int x = 0; x < image.cols; x++ ) {
for( int c = 0; c < 3; c++ ) {
new_image.at<Vec3b>(y,x)[c] =
saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
}
@ -155,11 +150,12 @@ Explanation
.. code-block :: cpp
for( int y = 0; y < image.rows; y++ )
{ for( int x = 0; x < image.cols; x++ )
{ for( int c = 0; c < 3; c++ )
{ new_image.at<Vec3b>(y,x)[c] =
saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta ); }
for( int y = 0; y < image.rows; y++ ) {
for( int x = 0; x < image.cols; x++ ) {
for( int c = 0; c < 3; c++ ) {
new_image.at<Vec3b>(y,x)[c] =
saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
}
}
}