//图片翻转
void COpenCVTestDlg::OnCbnSelchangeComboFlip()
{
if (m_comboFlip.GetCurSel() == -1)
return;
if (!m_srcMatImg.empty())
{
CString szFlip;
m_comboFlip.GetLBText(m_comboFlip.GetCurSel(), szFlip);
if (szFlip == L"水平翻转")
{
//水平方向翻转 参数值为1 参数>0位水平翻转
cv::flip(m_srcMatImg, m_dstMatImg, 1);
}
else if (szFlip == L"垂直翻转")
{
//垂直方向翻转 参数值为0 参数=0位垂直翻转
cv::flip(m_srcMatImg, m_dstMatImg, 0);
}
else
{
//水平和垂直方向同时翻转 参数值为-1 参数<0位水平垂直翻转
cv::flip(m_srcMatImg, m_dstMatImg, -1);
}
}
}
void flip(InputArray src, OutputArray dst, int flipCode);
src: is the original image to process
dst: is the target image with the same size and type as the original image
flipCode: is the rotation type
=0, flip the x-axis direction
>0, the y-axis direction is flipped
<0, the x-axis and y-axis are flipped at the same time
In this function, the relationship between the target pixel and the original pixel is expressed as:
Y方向翻转
cv::flip(m_srcImage, m_dstImage, 1);
X方向翻转
cv::flip(m_srcImage, m_dstImage, 0);
XY两方向翻转
cv::flip(m_srcImage, m_dstImage, -1);
original image
flip
There are also flip transformations written by themselves, please pay attention to the public account "Qt Learning Vision"