Raw data denoising of ISP module (i)

Source: Internet
Author: User

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?
  1. void Main ()
  2. {
  3. /******* began to write median filter denoising module--2015.07.27***********/
  4. De-noising for R component blocks
  5. pnewdoc->m_rblock = new unsigned short [M_HEIGHT*M_WIDTH/4];
  6. pnewdoc->m_g1block = new unsigned short [M_HEIGHT*M_WIDTH/4];
  7. pnewdoc->m_g2block = new unsigned short [M_HEIGHT*M_WIDTH/4];
  8. pnewdoc->m_bblock = new unsigned short [M_HEIGHT*M_WIDTH/4];
  9. unsigned short* smoothr = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
  10. unsigned short* smoothG1 = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
  11. unsigned short* smoothG2 = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
  12. unsigned short* SMOOTHB = new unsigned SHORT[M_HEIGHT*M_WIDTH/4];
  13. for (int i = 0; I < m_height/2; i + +)
  14. {
  15. for (int j = 0; J < M_width/2; j + +)
  16. {
  17. pnewdoc->m_rblock [I*m_width/2 + j] = m_rawimage[i*m_width*2 + j*2];
  18. pnewdoc->M_G1BLOCK[I*M_WIDTH/2 + j] = m_rawimage[i*m_width*2 + j*2 + 1];
  19. pnewdoc->M_G2BLOCK[I*M_WIDTH/2 + j] = m_rawimage[i*m_width*2 + m_width + j*2];
  20. pnewdoc->m_bblock [I*m_width/2 + j] = m_rawimage[i*m_width*2 + m_width + j*2 + 1];
  21. }
  22. }
  23. Medianfilter (pnewdoc->M_RBLOCK,SMOOTHR,M_WIDTH/2,M_HEIGHT/2); De-noising for R component blocks
  24. Medianfilter (pnewdoc->M_G1BLOCK,SMOOTHG1,M_WIDTH/2,M_HEIGHT/2);//de-noising for G1 component blocks
  25. Medianfilter (pnewdoc->M_G2BLOCK,SMOOTHG2,M_WIDTH/2,M_HEIGHT/2);//de-noising for G2 component blocks
  26. Medianfilter (pnewdoc->M_BBLOCK,SMOOTHB,M_WIDTH/2,M_HEIGHT/2); De-noising for B-component blocks
  27. In turn, it constructs the raw data after de-noising
  28. for (int i = 0; I < M_HEIGHT/2-1;i + +)
  29. {
  30. for (int j = 0; J < m_width/2-1; j + +)
  31. {
  32. pnewdoc->m_imagenr[i*m_width*2 + j*2] = Smoothr[i*m_width/2 + j];
  33. pnewdoc->m_imagenr[i*m_width*2 + j*2 + 1] = Smoothg1[i*m_width/2 + j];
  34. pnewdoc->m_imagenr[i*m_width*2 + m_width + j*2] = Smoothg2[i*m_width/2 + j];
  35. pnewdoc->m_imagenr[i*m_width*2 + m_width + j*2 + 1] = Smoothb[i*m_width/2 + j];
  36. }
  37. }
  38. /*********** Median filter module complete--2015.07.27********************/
  39. Saveimagedata (pnewdoc->m_imagenr, M_height, M_width, "e:\\m_imagenr.bmp");
  40. Setdisplayrawimage (pnewdoc->m_imagenr, M_height, M_width, m_rawbittype,pnewdoc->m_Image);
  41. }
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-&GT;M_RBLOCK,SMOOTHR,M_WIDTH/2,M_HEIGHT/2); Denoising Medianfilter (PNEWDOC-&GT;M_G1BLOCK,SMOOTHG1,M_WIDTH/2,M_HEIGHT/2) for r component blocks; De-noising Medianfilter (PNEWDOC-&GT;M_G2BLOCK,SMOOTHG2,M_WIDTH/2,M_HEIGHT/2) for G1 component blocks;   De-noising Medianfilter (PNEWDOC-&GT;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-&GT;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?
  1. <pre name="code" class="html">void medianfilter (unsigned short* corrupted, unsigned short* smooth, int width, int height)
  2. {
  3. memcpy (smooth, corrupted, width*height*sizeof (unsigned short));
  4. for (int j=1;j<height-1;j++)
  5. {
  6. for (int i=1;i<width-1;i++)
  7. {
  8. int k = 0;
  9. unsigned short window[9];
  10. for (int JJ = j-1; JJ < j + 2; ++jj)
  11. for (int II = i-1; II < i + 2; ++ii)
  12. window[k++] = CORRUPTED[JJ * width + II];
  13. Order elements (only half of them)
  14. for (int m = 0; M < 5; ++m)
  15. {
  16. int min = m;
  17. for (int n = m + 1; n < 9; ++n)
  18. if (Window[n] < window[min])
  19. min = n;
  20. Put found minimum element in it place
  21. unsigned short temp = window[m];
  22. WINDOW[M] = Window[min];
  23. Window[min] = temp;
  24. }
  25. smooth[J*width+i] = window[4];
  26. }
  27. }
  28. } <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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.