summaryrefslogtreecommitdiff
path: root/sci_gateway/cpp/opencv_ifftshift.cpp
diff options
context:
space:
mode:
authorshamikam2017-01-16 02:56:17 +0530
committershamikam2017-01-16 02:56:17 +0530
commita6df67e8bcd5159cde27556f4f6a315f8dc2215f (patch)
treee806e966b06a53388fb300d89534354b222c2cad /sci_gateway/cpp/opencv_ifftshift.cpp
downloadFOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.gz
FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.bz2
FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.zip
First CommitHEADmaster
Diffstat (limited to 'sci_gateway/cpp/opencv_ifftshift.cpp')
-rw-r--r--sci_gateway/cpp/opencv_ifftshift.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/sci_gateway/cpp/opencv_ifftshift.cpp b/sci_gateway/cpp/opencv_ifftshift.cpp
new file mode 100644
index 0000000..8bf6ba2
--- /dev/null
+++ b/sci_gateway/cpp/opencv_ifftshift.cpp
@@ -0,0 +1,55 @@
+/********************************************************
+Function :ifftshift
+Syntax :B=ifftshift(A)
+Author : Tess Zacharias
+********************************************************/
+
+#include <numeric>
+#include "opencv2/core/core.hpp"
+#include "opencv2/highgui/highgui.hpp"
+#include "opencv2/opencv.hpp"
+#include <iostream>
+#include "string.h"
+using namespace cv;
+using namespace std;
+extern "C"
+{
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "BOOL.h"
+ #include <localization.h>
+ #include "sciprint.h"
+ #include "../common.h"
+ int opencv_ifftshift(char *fname, unsigned long fname_len)
+ {
+
+ SciErr sciErr;
+ Mat image;
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1) ;
+ retrieveImage(image,1);
+ int cx = floor(image.cols/2);
+ int cy = floor(image.rows/2);
+ Mat q0(image, Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
+ Mat q1(image, Rect(cx, 0, cx, cy)); // Top-Right
+ Mat q2(image, Rect(0, cy, cx, cy)); // Bottom-Left
+ Mat q3(image, Rect(cx, cy, cx, cy)); // Bottom-Right
+ Mat tmp; // swap quadrants (Top-Left with Bottom-Right)
+ q0.copyTo(tmp);
+ q3.copyTo(q0);
+ tmp.copyTo(q3);
+ q1.copyTo(tmp); // swap quadrant (Top-Right with Bottom-Left)
+ q2.copyTo(q1);
+ tmp.copyTo(q2);
+ int temp = nbInputArgument(pvApiCtx) + 1;
+ string tempstring = type2str(image.type());
+ char *checker;
+ checker = (char *)malloc(tempstring.size() + 1);
+ memcpy(checker, tempstring.c_str(), tempstring.size() + 1);
+ returnImage(checker,image,1);
+ free(checker);
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ ReturnArguments(pvApiCtx);
+ return 0;
+ }
+}