![]() |
These are satellite photos of the nuclear facilities in Yongbyon, DPRK. On October 3, 2006, North Korea decleared to test its nuclear bombs. At this very moment, the UN Security Council countries is debating, to show strong stand against North Korea.
The photo under is a mosaic image of the nuclear facilities above. The whole area is divided into equal sized cells and colored in the average RGB value, which is the mean RGB value of the area surrounding the center point of the each cell.
The following piece of code shows the function that does the processing. The funcion takes the pointer to the region and draws the mosaic image to the specified CDC class. The grainsize parameter is the size of each cell. The Average() function returns the average RGB value of the location (for more information on Average() function → Color Selection).
void CPhotoDialog::DrawMosaicRegion(CRect* pRect, CDC* pDC, int grainsize)
{
int i=0,j=0;
for(i=pRect->left;i<pRect->right;i+=grainsize)
for(j=pRect->top;j<pRect->bottom;j+=grainsize)
{
int x=i+step,y=j+step;
if(pRect->right<x)
x=pRect->right;
if(pRect->bottom<y)
y=pRect->bottom;
COLORREF rgb;
rgb=Average((i+x)/2,(j+y)/2);
CBrush brush(rgb);
pDC->FillRect(CRect(i,j,x,y),&brush);
}
}