perspective 과제, 변환 여러번 가능하도록 짜기

This commit is contained in:
USW
2025-04-09 12:02:15 +09:00
parent f2f018da0c
commit ecfb02b693
7 changed files with 506 additions and 0 deletions

View File

@@ -51,6 +51,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Homework", "Homework", "{E5
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "noise_denoise", "Homework\noise_denoise\noise_denoise.vcxproj", "{C91F6DA7-8B51-4630-9340-D3643FE0531E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ch08", "ch08", "{610D1B36-71E3-4C3D-B0CE-2C563B0504A6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "affine", "ch08\affine\affine.vcxproj", "{E0970C66-807B-4090-83C4-C71227BD2AFF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perspective", "Homework\perspective\perspective.vcxproj", "{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -187,6 +193,22 @@ Global
{C91F6DA7-8B51-4630-9340-D3643FE0531E}.Release|x64.Build.0 = Release|x64
{C91F6DA7-8B51-4630-9340-D3643FE0531E}.Release|x86.ActiveCfg = Release|Win32
{C91F6DA7-8B51-4630-9340-D3643FE0531E}.Release|x86.Build.0 = Release|Win32
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Debug|x64.ActiveCfg = Debug|x64
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Debug|x64.Build.0 = Debug|x64
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Debug|x86.ActiveCfg = Debug|Win32
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Debug|x86.Build.0 = Debug|Win32
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Release|x64.ActiveCfg = Release|x64
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Release|x64.Build.0 = Release|x64
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Release|x86.ActiveCfg = Release|Win32
{E0970C66-807B-4090-83C4-C71227BD2AFF}.Release|x86.Build.0 = Release|Win32
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Debug|x64.ActiveCfg = Debug|x64
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Debug|x64.Build.0 = Debug|x64
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Debug|x86.ActiveCfg = Debug|Win32
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Debug|x86.Build.0 = Debug|Win32
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Release|x64.ActiveCfg = Release|x64
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Release|x64.Build.0 = Release|x64
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Release|x86.ActiveCfg = Release|Win32
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -208,6 +230,8 @@ Global
{A871F9D8-2DD0-4B01-A304-E738968313F2} = {E0A91F3E-0B54-4785-AB66-727A7EE1E15B}
{380222EF-FFE1-445F-B409-1DD866DF1ED9} = {E0A91F3E-0B54-4785-AB66-727A7EE1E15B}
{C91F6DA7-8B51-4630-9340-D3643FE0531E} = {E583E257-9FCE-4A4B-A554-8514F982D1BF}
{E0970C66-807B-4090-83C4-C71227BD2AFF} = {610D1B36-71E3-4C3D-B0CE-2C563B0504A6}
{F920D051-F9B5-43C2-ACF7-C5DE9B18B20C} = {E583E257-9FCE-4A4B-A554-8514F982D1BF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E1A0C3F4-F16D-4626-86CE-D8484C0C776D}

View File

@@ -0,0 +1,11 @@
#include <iostream>
#include <array>
#include <cstdint>
#include <cmath>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main() {
}

View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{f920d051-f9b5-43c2-acf7-c5de9b18b20c}</ProjectGuid>
<RootNamespace>perspective</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_debug.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_release.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_debug.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_release.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="소스 파일">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="헤더 파일">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="리소스 파일">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
</ItemGroup>
</Project>

143
ch08/affine/affine.vcxproj Normal file
View File

@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{e0970c66-807b-4090-83c4-c71227bd2aff}</ProjectGuid>
<RootNamespace>affine</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_debug.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_release.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_debug.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\OPENCV4110_release.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\resources\images\lenna.bmp" />
<Image Include="..\..\resources\images\tekapo.bmp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="소스 파일">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="헤더 파일">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="리소스 파일">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="..\..\resources\images\tekapo.bmp">
<Filter>리소스 파일</Filter>
</Image>
<Image Include="..\..\resources\images\lenna.bmp">
<Filter>리소스 파일</Filter>
</Image>
</ItemGroup>
</Project>

137
ch08/affine/main.cpp Normal file
View File

@@ -0,0 +1,137 @@
#include <iostream>
#include <array>
#include <cstdint>
#include <cmath>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
void affine_flip() {
Mat src = imread("../../resources/images/eastsea.bmp");
imshow("src", src);
Mat dst;
int flipCode[] = { 1, 0, -1 };
for (int i = 0; i < 3; i++) {
flip(src, dst, flipCode[i]);
String desc = format("filpcode: %d", flipCode[i]);
putText(dst, desc, Point(10, 30), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(255, 0, 0), 1, LINE_AA);
imshow("dst", dst);
waitKey();
}
destroyAllWindows();
}
void affine_rotation() {
Mat src = imread("../../resources/images/tekapo.bmp");
Point2f cp(src.cols / 2.f, src.rows / 2.f);
array<float_t, 6> data = { 0.f, 0.f, cos(20 * 3.141592 / 180), 0.f, 0.f, sin(20 * 3.141592 / 180) };
Mat M(2, 3, CV_32F, data.data());
M += getRotationMatrix2D(cp, 20, 1);
Mat dst;
warpAffine(src, dst, M, Size(src.cols + cos(20 * 3.141592 / 180), src.rows + sin(20 * 3.141592 / 180)));
imshow("src", src);
imshow("dst", dst);
waitKey();
destroyAllWindows();
}
void affine_scale() {
Mat src = imread("../../resources/images/rose.bmp");
Mat dst1, dst2, dst3, dst4;
resize(src, dst1, Size(), 4, 4, INTER_NEAREST);
resize(src, dst2, Size(1920, 1280));
resize(src, dst3, Size(1920, 1280), 0, 0, INTER_CUBIC);
resize(src, dst4, Size(1920 * 2, 1280 * 2), 0, 0, INTER_LANCZOS4);
imshow("src", src);
imshow("dst1", dst1(Rect(400, 500, 400, 400)));
imshow("dst2", dst2(Rect(400, 500, 400, 400)));
imshow("dst3", dst3(Rect(400, 500, 400, 400)));
imshow("dst4", dst4(Rect(800, 1000, 400, 400)));
waitKey();
destroyAllWindows();
}
void affine_shear() {
Mat src = imread("../../resources/images/tekapo.bmp");
double_t mx = tan(15 * 3.141592 / 180); // x축에 대해 각도만큼 기울이는 코드
double_t my = tan(15 * 3.141592 / 180); // y축에 대해 각도만큼 기울이는 코드
Mat M = Mat_<double_t>({ 2, 3 }, { 1, mx, 0, my, 1, 0 }), dst;
warpAffine(src, dst, M, Size(cvRound(src.cols + src.rows * mx), cvRound(src.rows + src.cols * my)));
imshow("src", src);
imshow("dst", dst);
waitKey();
destroyAllWindows();
}
void affine_translation() {
Mat src = imread("../../resources/images/tekapo.bmp");
Mat M = Mat_<double_t>({ 2, 3 }, { 1, 0, 150, 0, 1, 100 }), dst;
Size _new_size = src.size();
_new_size.width += 150 * 2;
_new_size.height += 100 * 2;
warpAffine(src, dst, M, _new_size);
imshow("src", src);
imshow("dst", dst);
waitKey();
destroyAllWindows();
}
void affine_transform() {
Mat src = imread("../../resources/images/tekapo.bmp");
/*Point2f srcPts[3] = {
Point2f(0, 0),
Point2f(src.cols - 1, 0),
Point2f(src.cols - 1, src.rows - 1)
}, dstPts[3] = {
Point2f(50, 50),
Point2f(src.cols - 100, 100),
Point2f(src.cols - 50, src.rows - 50)
};*/
array<float_t, 6> data = { 0.8f, 0.f, 30.f, 0.f, 0.8f, 30.f };
Mat M(2, 3, CV_32F, data.data());
Mat dst = imread("../../resources/images/lenna.bmp");
warpAffine(src, dst, M, Size(), INTER_LINEAR, BORDER_CONSTANT, Scalar(50, 50, 100));
vector<Point2f> sP = { Point2f(10, 10), Point2f(30, 70), Point2f(100, 80) }, tP;
transform(sP, tP, M);
Mat cM = getAffineTransform(sP, tP);
cout << "Transform matrix M : " << M << endl;
cout << "Calculated matrix cM : " << cM << endl;
imshow("src", src);
imshow("dst", dst);
waitKey();
destroyAllWindows();
}
int main() {
affine_rotation();
return 0;
}