What steps will reproduce the problem?
1. Improve gaussianBlur() or take my improved code
2.
3.
What is the expected output? What do you see instead?
gaussianBlur() reduces image by 5 pixels in the upper left corner.
What version of the product are you using? On what operating system?
xCode and the newest version (13th july 2010)
Please provide any additional information below.
Fixed gaussianBlur() function:
ImageWrapper *Image::gaussianBlur() {
Image *result=new Image(m_width, m_height);
for(int y = 0; y < m_height; y++) {
for(int x = 0; x < m_width; x++) {
int val = (*this)[y][x]*41; //Declare currents pixels value
int middle = 41; //Declare average
if (x > 0) { val += (*this)[y][x-1] *26;middle += 26;}
if (x > 1) { val += (*this)[y][x-2] *7; middle += 7;}
if (x < m_width-1) { val += (*this)[y][x+1] *26;middle += 26;}
if (x < m_width-2) { val += (*this)[y][x+2] *7; middle += 7;}
if (y > 0) { val += (*this)[y-1][x] *26;middle += 26;}
if (y > 0 && x > 0) { val += (*this)[y-1][x-1] *16;middle += 16;}
if (y > 0 && x > 1) { val += (*this)[y-1][x-2] *4; middle += 4;}
if (y > 0 && x < m_width-1) { val += (*this)[y-1][x+1] *16;middle += 16;}
if (y > 0 && x < m_width-2) { val += (*this)[y-1][x+2] *4; middle += 4;}
if (y > 1) { val += (*this)[y-2][x] *7; middle += 7;}
if (y > 1 && x > 0) { val += (*this)[y-2][x-1] *4; middle += 4;}
if (y > 1 && x > 1) { val += (*this)[y-2][x-2] *1; middle += 1;}
if (y > 1 && x < m_width-1) { val += (*this)[y-2][x+1] *4; middle += 4;}
if (y > 1 && x < m_width-2) { val += (*this)[y-2][x+2] *1; middle += 1;}
if (y < m_height-1) { val += (*this)[y+1][x] *26;middle += 26;}
if (y < m_height-1 && x > 0) { val += (*this)[y+1][x-1] *16;middle += 16;}
if (y < m_height-1 && x > 1) { val += (*this)[y+1][x-2] *4; middle += 4;}
if (y < m_height-1 && x < m_width-1){ val += (*this)[y+1][x+1] *16;middle += 16;}
if (y < m_height-1 && x < m_width-2){ val += (*this)[y+1][x+2] *4; middle += 4;}
if (y < m_height-2) { val += (*this)[y+2][x] *7; middle += 7;}
if (y < m_height-2 && x > 0) { val += (*this)[y+2][x-1] *4; middle += 4;}
if (y < m_height-2 && x > 1) { val += (*this)[y+2][x-2] *1; middle += 1;}
if (y < m_height-2 && x < m_width-1){ val += (*this)[y+2][x+1] *4; middle += 4;}
if (y < m_height-2 && x < m_width-2){ val += (*this)[y+2][x+2] *1; middle += 1;}
(*result)[y][x] = (int)val/middle; //Calculating average value for given pixel
}
}
return [ImageWrapper imageWithCPPImage:result]; //Return the image
}
Original issue reported on code.google.com by Me.Te...@gmail.com on 13 Jul 2010 at 7:10
Original issue reported on code.google.com by
Me.Te...@gmail.com
on 13 Jul 2010 at 7:10