The ISP (Image Signal Processor), a signal processor , is mainly used for the front-end image sensor output signal processing unit, mainly used in mobile phones, surveillance cameras and other devices.
RawData can be understood as: RAW image is the CMOS or CCD image sensor will capture the source of the signal into the original digital signal, is lossless, including the original color information of the object. Raw data format is generally used in the Bayer arrangement , through the filter light, to produce a color filter array (CFA), in view of the human eye on the green band of color more sensitive, the Bayer data format contains 50% of green information, and 25 % of red and blue information.
There are 4 types of Bayer in the following formats:
1.| T: G | 2.| B | G | 3.| G | T: 4.| G | B |
| G | B | | G | T: | B | G | | T: G |
The first part of the ISP processing module is the need to de-noising the CFA data. The common denoising method is inappropriate for Bayer data format and needs to be transformed before processing can be done.
One, median filter CFA (Color filter Array) Data denoising method
First of all, let's review the algorithm principle and advantages and disadvantages of median filtering, and then give a schematic algorithm.
Median filtering, as the name implies, is to sort all the pixel values in the filter, and then replace the current pixel value with the median value. The common median filter has 3x3,5x5 and so on.
The median filter is a bit of a simple implementation that can effectively eliminate salt and pepper noise and other pulse-type noise. The disadvantage is that all denoising algorithms are common, that is, the content of the image is smoothed blurred, some corner points and the loss of information on the edge.
When the CFA data is de-noising, different color channels need to be processed separately in order to prevent the loss of useful color information in the smoothing process, for example, when the blue pixels surrounded by green information differ greatly from each other, the noise is considered to be processed, but the real situation is that The blue information in this area is very large. So each channel alone is conducive to the protection of color information. In my process, the original CFA data is divided into 4 pieces of-r,g1,g2,b, block Denoising completed and then restored to the original position, so that the entire process is completed.
The following is the reference median filter and the C + + (MFC) Code of the main program:
Main function:
[HTML]View Plaincopy print?
- void Main ()
- {
- /******* began to write median filter denoising module--2015.07.27***********/
- De-noising for R component blocks
- pnewdoc->m_rblock = new unsigned short [M_HEIGHT*M_WIDTH/4];
- pnewdoc->m_g1block = new unsigned short [M_HEIGHT*M_WIDTH/4];
- pnewdoc->m_g2block = new unsigned short [M_HEIGHT*M_WIDTH/4];
- pnewdoc->m_bblock = new unsigned short [M_HEIGHT*M_WIDTH/4];
- unsigned short* smoothr = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
- unsigned short* smoothG1 = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
- unsigned short* smoothG2 = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
- unsigned short* SMOOTHB = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
- for (int i = 0; I < m_height/2; i + +)
- {
- for (int j = 0; J < M_width/2; j + +)
- {
- pnewdoc->m_rblock [I*m_width/2 + j] = m_rawimage[i*m_width*2 + j*2];
- pnewdoc->M_G1BLOCK[I*M_WIDTH/2 + j] = m_rawimage[i*m_width*2 + j*2 + 1];
- pnewdoc->M_G2BLOCK[I*M_WIDTH/2 + j] = m_rawimage[i*m_width*2 + m_width + j*2];
- pnewdoc->m_bblock [I*m_width/2 + j] = m_rawimage[i*m_width*2 + m_width + j*2 + 1];
- }
- }
- Medianfilter (pnewdoc->M_RBLOCK,SMOOTHR,M_WIDTH/2,M_HEIGHT/2); De-noising for R component blocks
- Medianfilter (pnewdoc->M_G1BLOCK,SMOOTHG1,M_WIDTH/2,M_HEIGHT/2);//de-noising for G1 component blocks
- Medianfilter (pnewdoc->M_G2BLOCK,SMOOTHG2,M_WIDTH/2,M_HEIGHT/2);//de-noising for G2 component blocks
- Medianfilter (pnewdoc->M_BBLOCK,SMOOTHB,M_WIDTH/2,M_HEIGHT/2); De-noising for B-component blocks
- In turn, it constructs the raw data after de-noising
- for (int i = 0; I < M_HEIGHT/2-1;i + +)
- {
- for (int j = 0; J < m_width/2-1; j + +)
- {
- pnewdoc->m_imagenr[i*m_width*2 + j*2] = Smoothr[i*m_width/2 + j];
- pnewdoc->m_imagenr[i*m_width*2 + j*2 + 1] = Smoothg1[i*m_width/2 + j];
- pnewdoc->m_imagenr[i*m_width*2 + m_width + j*2] = Smoothg2[i*m_width/2 + j];
- pnewdoc->m_imagenr[i*m_width*2 + m_width + j*2 + 1] = Smoothb[i*m_width/2 + j];
- }
- }
- /*********** Median filter module complete--2015.07.27********************/
- Saveimagedata (pnewdoc->m_imagenr, M_height, M_width, "e:\\m_imagenr.bmp");
- Setdisplayrawimage (pnewdoc->m_imagenr, M_height, M_width, m_rawbittype,pnewdoc->m_Image);
- }
void Main () {/******* begins writing median filter denoising module--2015.07.27***********///for r component Pnewdoc->m_rblock = new unsigned short [m_ HEIGHT*M_WIDTH/4];p newdoc->m_g1block = new unsigned short [M_HEIGHT*M_WIDTH/4];p newdoc->m_g2block = new unsigned Short [M_HEIGHT*M_WIDTH/4];p newdoc->m_bblock = new unsigned short [m_height*m_width/4];unsigned short* smoothr = new unsigned short[m_height*m_width/4];unsigned short* smoothG1 = new unsigned short[m_height*m_width/4];unsigned short* smoothG2 = new unsigned short[m_height*m_width/4];unsigned short* SMOOTHB = new unsigned short[m_height*m_width/4];for (i NT i = 0; i < M_HEIGHT/2; i + +) {for (int j = 0; J < M_width/2; J + +) {Pnewdoc->m_rblock [I*m_width/2 + j] = M_rawimage[i*m _width*2 + j*2];p newdoc->m_g1block[i*m_width/2 + j] = m_rawimage[i*m_width*2 + j*2 + 1];p newdoc->m_g2block[i*m_ WIDTH/2 + j] = m_rawimage[i*m_width*2 + m_width + j*2];p Newdoc->m_bblock [I*m_width/2 + j] = m_rawimage[i*m_width*2 + M _width + j*2 + 1];}} Medianfilter (PNEWDOC->M_RBLOCK,SMOOTHR,M_WIDTH/2,M_HEIGHT/2); Denoising Medianfilter (PNEWDOC->M_G1BLOCK,SMOOTHG1,M_WIDTH/2,M_HEIGHT/2) for r component blocks; De-noising Medianfilter (PNEWDOC->M_G2BLOCK,SMOOTHG2,M_WIDTH/2,M_HEIGHT/2) for G1 component blocks; De-noising Medianfilter (PNEWDOC->M_BBLOCK,SMOOTHB,M_WIDTH/2,M_HEIGHT/2) for G2 component blocks; De-noising for B-component blocks//In turn constructs the raw datafor after de-noising (int i = 0; i < M_HEIGHT/2-1;i + +) {for (int j = 0; J < m_width/2-1; J + +) {PN Ewdoc->m_imagenr[i*m_width*2 + j*2] = Smoothr[i*m_width/2 + j];p newdoc->m_imagenr[i*m_width*2 + j*2 + 1] = smoothG1[ I*M_WIDTH/2 + j]; Pnewdoc->m_imagenr[i*m_width*2 + m_width + j*2] = Smoothg2[i*m_width/2 + j];p newdoc->m_imagenr[i*m_width*2 + m_ Width + j*2 + 1] = Smoothb[i*m_width/2 + j];}} /*********** Median filter module completed--2015.07.27********************///saveimagedata (PNEWDOC->M_IMAGENR, M_Height, M_Width, "E : \\m_ImageNR.bmp "); Setdisplayrawimage (Pnewdoc->m_imagenr, M_height, M_width, m_rawbittype,pnewdoc->m_image);}
[HTML]View Plaincopy print?
- <pre name="code" class="html">void medianfilter (unsigned short* corrupted, unsigned short* smooth, int width, int height)
- {
- memcpy (smooth, corrupted, width*height*sizeof (unsigned short));
- for (int j=1;j<height-1;j++)
- {
- for (int i=1;i<width-1;i++)
- {
- int k = 0;
- unsigned short window[9];
- for (int JJ = j-1; JJ < j + 2; ++jj)
- for (int II = i-1; II < i + 2; ++ii)
- window[k++] = CORRUPTED[JJ * width + II];
- Order elements (only half of them)
- for (int m = 0; M < 5; ++m)
- {
- int min = m;
- for (int n = m + 1; n < 9; ++n)
- if (Window[n] < window[min])
- min = n;
- Put found minimum element in it place
- unsigned short temp = window[m];
- WINDOW[M] = Window[min];
- Window[min] = temp;
- }
- smooth[J*width+i] = window[4];
- }
- }
- } <span style=< Span class= "Attribute-value" > "font-family: arial, helvetica, sans-serif;" > </span>
<pre name= "code" class= "HTML" >void medianfilter (unsigned short* corrupted, unsigned short* smooth, int width, int h Eight) {memcpy (smooth, corrupted, width*height*sizeof (unsigned short)); for (int j=1;j
[HTML]View Plaincopy print?
Median filter function is to find the code on the Internet, because of the comparative basis, it is directly used, invasion and deletion
Before and after noise removal:
Next article, I will mainly show you the BM3D algorithm raw data denoising effect, thank you.
Raw data denoising of ISP module (i)