1
edit
Changes
→Assignment 1
== Progress ==
=== Assignment 1 ===
===Image Manipulation===
Image Resampling/Rescaling is the method used to create a new and potentially better version of an image with a different size. I chose to decipher the code mentioned on http://www.cplusplus.com/forum/general/2615/ to better understand how it works.
The following performs a basic pixel enlarging resample:
bool Resample(int newWidth, int newHeight)
{
if(_data == NULL) return false;
//
// Get a new buuffer to interpolate into
unsigned char* newData = new unsigned char [newWidth * newHeight * 3];
double scaleWidth = (double)newWidth / (double)_width;
double scaleHeight = (double)newHeight / (double)_height;
for(int cy = 0; cy < newHeight; cy++)
{
for(int cx = 0; cx < newWidth; cx++)
{
int pixel = (cy * (newWidth *3)) + (cx*3);
int nearestMatch = (((int)(cy / scaleHeight) * (_width *3)) + ((int)(cx / scaleWidth) *3) );
newData[pixel ] = _data[nearestMatch ];
newData[pixel + 1] = _data[nearestMatch + 1];
newData[pixel + 2] = _data[nearestMatch + 2];
}
}
}
However, I've noticed the code needed to be modified so the user can decide the dimensions of the image instead of it being hard coded. Therefore, we can parallelize the above portion of the code to make it more efficient while looking similar to the for loops but functions differently and potentially better at runtime.
The following displays the gprof profile:
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
100.00 0.03 RawBitMap::Resample(int,int)
0.00 0.03 0.00 1 0.00 0.00 _GLOBAL__sub_I_main
=== Assignment 2 ===
=== Assignment 3 ===