#include <iostream>
using namespace std;
int main() {
// your code goes here
int m_height = 3072;
int m_width = 4096;
const int oriRows = m_height / 2;
const int oriCols = m_width / 2;
const int tgtRows = m_height;
const int tgtCols = m_width;
const int oriSize = oriRows * oriCols;
const int tgtSize = tgtRows * tgtCols;
float rowFactor = (float)(oriRows) / tgtRows;
float colFactor = (float)(oriCols) / tgtCols;
int tgtIndex = 0;
// rOffser is zero
int oriGROffset = oriSize;
int oriGBOffset = 2 * oriSize;
int oriBOffset = 3 * oriSize;
int r = 2;
int c = 2;
float oriRowF = r * rowFactor;
float oriColF = c * colFactor;
// Get the integer and fractional parts of the coordinates
int oriRowI1 = (int)oriRowF;
int oriColI1 = (int)oriColF;
int oriRowI2 = min(oriRowI1 + 1, oriRows - 1); // Clamp to max row index
int oriColI2 = min(oriColI1 + 1, oriCols - 1); // Clamp to max col index
printf("oriRowI1 = %d\n", oriRowI1);
printf("oriColI1 = %d\n", oriColI1);
printf("oriRowI2 = %d\n", oriRowI2);
printf("oriColI2 = %d\n", oriColI2);
float deltaRow = oriRowF - oriRowI1;
float deltaCol = oriColF - oriColI1;
printf("deltaRow = %f\n", deltaRow);
printf("deltaCol = %f\n", deltaCol);
// Get the four neighboring pixel values from the original array
int tempPos11 = oriRowI1 * oriCols + oriColI1;
int tempPos12 = oriRowI1 * oriCols + oriColI2;
int tempPos21 = oriRowI2 * oriCols + oriColI1;
int tempPos22 = oriRowI2 * oriCols + oriColI2;
printf("tempPos11 = %d\n", tempPos11);
printf("tempPos12 = %d\n", tempPos12);
printf("tempPos21 = %d\n", tempPos21);
printf("tempPos22 = %d\n", tempPos22);
/*float r11 = (float)m_imgInput[tempPos11];
float r12 = (float)m_imgInput[tempPos12];
float r21 = (float)m_imgInput[tempPos21];
float r22 = (float)m_imgInput[tempPos22];
float gr11 = (float)m_imgInput[tempPos11 + oriGROffset];
float gr12 = (float)m_imgInput[tempPos12 + oriGROffset];
float gr21 = (float)m_imgInput[tempPos21 + oriGROffset];
float gr22 = (float)m_imgInput[tempPos22 + oriGROffset];
float gb11 = (float)m_imgInput[tempPos11 + oriGBOffset];
float gb12 = (float)m_imgInput[tempPos12 + oriGBOffset];
float gb21 = (float)m_imgInput[tempPos21 + oriGBOffset];
float gb22 = (float)m_imgInput[tempPos22 + oriGBOffset];
float b11 = (float)m_imgInput[tempPos11 + oriBOffset];
float b12 = (float)m_imgInput[tempPos12 + oriBOffset];
float b21 = (float)m_imgInput[tempPos21 + oriBOffset];
float b22 = (float)m_imgInput[tempPos22 + oriBOffset];
//printf("r11[%d] %f, ", oriRowI1 * oriCols + oriColI1, r11);
//printf("r12[%d] %f, ", oriRowI1 * oriCols + oriColI2, r12);
//printf("r21[%d] %f, ", oriRowI2 * oriCols + oriColI1, r21);
//printf("r22[%d] %f, ", oriRowI2 * oriCols + oriColI2, r22);
// Bilinear interpolation
float interpoR =
r11 * (1 - deltaRow) * (1 - deltaCol) +
r21 * deltaRow * (1 - deltaCol) +
r12 * (1 - deltaRow) * deltaCol +
r22 * deltaRow * deltaCol;
float interpoGR =
gr11 * (1 - deltaRow) * (1 - deltaCol) +
gr21 * deltaRow * (1 - deltaCol) +
gr12 * (1 - deltaRow) * deltaCol +
gr22 * deltaRow * deltaCol;
float interpoGB =
gb11 * (1 - deltaRow) * (1 - deltaCol) +
gb21 * deltaRow * (1 - deltaCol) +
gb12 * (1 - deltaRow) * deltaCol +
gb22 * deltaRow * deltaCol;
float interpoB =
b11 * (1 - deltaRow) * (1 - deltaCol) +
b21 * deltaRow * (1 - deltaCol) +
b12 * (1 - deltaRow) * deltaCol +
b22 * deltaRow * deltaCol;*/
return 0;
}