Flip and save an image in Opencv - C++

Advertisemen

Add following codes(codes that are highlighted) to the existing codes from our last tutorial.

Like before, we declared variable and named it result.

flip(InputArray src, OutputArray dst, int flipCode)



  • src – input array.
  • dst – output array of the same size and type as src.
  • flipCode – a flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes (see the discussion below for the formulas).

imwrite saves image in same folder as original with the name specified.

full codes will look like this :
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main()
{
cv::Mat image; // 1
image = cv::imread("binary.jpg"); // 2
cv::namedWindow("Aarlangdi Original Image"); //3
cv::imshow("Aarlangdi Original Image", image); // 4
cv::Mat result;
cv::flip(image, result, 1);

cv::namedWindow("windowTwo");
cv::imshow("windowTwo", result);

// saving image
cv::imwrite("binaryModified.jpg", result);

cv::waitKey(0); //5
}

Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D