
Assembler Optimization on PC
5562
£100(approx. $134)
- Posted:
- Proposals: 1
- Remote
- #54620
- Archived
Description
Experience Level: Intermediate
I need an optimized assembler program to take a 640x480 8-bit image and reduce it to 160x120 resolution as follows:
For each 4x4 collection of pixels in the source image, calculate the average of all the non-zero pixels and store that average in the destination 160x120 image. If a pixel value in the source image is zero it must be ignored and not included in the destination image. If all source image pixels in a block are zero then the destination image should be set to zero.
The C code for this would look something like:
ImageAverageShrinkNoZeros(unsigned char *pSource, unsigned char *pDest)
unsigned char *pRow1, *pRow2, *pRow3, *pRow4;
int nTotal;
int nPixelCnt;
int nRow,nCol,I;
pRow1 = pSource;
for (nRow=0; nRow<480; nRow+=4)
{
pRow1 = pSource + 640 * nRow;
pRow2 = pRow1 + 640;
pRow3 = pRow2 + 640;
pRow4 = pRow3 + 640;
for(nCol=0; nCol<640; nCol+=4)
{
nTotal = 0;
nPixelCnt = 0;
for(i=0;i<4;i++)
{
if(*pRow1 > 0) { nTotal += *pRow1++; nPixelCnt++; } else pRow1++;
if(*pRow2 > 0) { nTotal += *pRow2++; nPixelCnt++; } else pRow2++;
if(*pRow3 > 0) { nTotal += *pRow3++; nPixelCnt++; } else pRow3++;
if(*pRow4 > 0) { nTotal += *pRow4++; nPixelCnt++; } else pRow4++;
}
if(nPixelCnt > 0)
*pDest++ = (unsigned char) (nTotal / nPixelCnt);
else
*pDest++ = 0;
}
}
I need this to run very quickly on a PC in windows.
For each 4x4 collection of pixels in the source image, calculate the average of all the non-zero pixels and store that average in the destination 160x120 image. If a pixel value in the source image is zero it must be ignored and not included in the destination image. If all source image pixels in a block are zero then the destination image should be set to zero.
The C code for this would look something like:
ImageAverageShrinkNoZeros(unsigned char *pSource, unsigned char *pDest)
unsigned char *pRow1, *pRow2, *pRow3, *pRow4;
int nTotal;
int nPixelCnt;
int nRow,nCol,I;
pRow1 = pSource;
for (nRow=0; nRow<480; nRow+=4)
{
pRow1 = pSource + 640 * nRow;
pRow2 = pRow1 + 640;
pRow3 = pRow2 + 640;
pRow4 = pRow3 + 640;
for(nCol=0; nCol<640; nCol+=4)
{
nTotal = 0;
nPixelCnt = 0;
for(i=0;i<4;i++)
{
if(*pRow1 > 0) { nTotal += *pRow1++; nPixelCnt++; } else pRow1++;
if(*pRow2 > 0) { nTotal += *pRow2++; nPixelCnt++; } else pRow2++;
if(*pRow3 > 0) { nTotal += *pRow3++; nPixelCnt++; } else pRow3++;
if(*pRow4 > 0) { nTotal += *pRow4++; nPixelCnt++; } else pRow4++;
}
if(nPixelCnt > 0)
*pDest++ = (unsigned char) (nTotal / nPixelCnt);
else
*pDest++ = 0;
}
}
I need this to run very quickly on a PC in windows.
Francis M.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
0%
Last project
18 May 2026
Canada
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies