Difference between revisions of "JP4"

From ElphelWiki
Jump to: navigation, search
Line 1: Line 1:
 
== JP4 format ==
 
== JP4 format ==
  
So we have added a special JP4 mode that bypasses the Demosaic in the FPGA and provides an image with pixels in each 16x16 macroblock that are rearranged to separate Bayer colors in individual 8x8 blocks, then encoded as monochrome. Demosaic will be applied during post-processing on the host PC. This section describe different algorithms and implementations used to provide this functionality.
+
So we have added a special JP4 mode that bypasses the Demosaic in the FPGA and provides an image with pixels in each 16x16 macroblock that are rearranged to separate Bayer colors in individual 8x8 blocks, then encoded as monochrome. [http://wiki.elphel.com/index.php?title=Demosaic_on_client_side Demosaic] will be applied during post-processing on the host PC. This section describe different algorithms and implementations used to provide this functionality.
  
 
Main goals:
 
Main goals:
Line 41: Line 41:
 
JP4 stream can be decoded by mplayer.
 
JP4 stream can be decoded by mplayer.
 
Use this patch for glue libdc1394 and mplayer video filter frontend.
 
Use this patch for glue libdc1394 and mplayer video filter frontend.
  Debayer algorithm variants provided by libdc1394:
+
  Debayer ([http://wiki.elphel.com/index.php?title=Demosaic_on_client_side Demosaic]) algorithm variants provided by libdc1394:
 
  - Nearest Neighbor
 
  - Nearest Neighbor
 
  - Simple AVT
 
  - Simple AVT

Revision as of 08:11, 19 November 2008

JP4 format

So we have added a special JP4 mode that bypasses the Demosaic in the FPGA and provides an image with pixels in each 16x16 macroblock that are rearranged to separate Bayer colors in individual 8x8 blocks, then encoded as monochrome. Demosaic will be applied during post-processing on the host PC. This section describe different algorithms and implementations used to provide this functionality.

Main goals:

- compression speed improvement
- possibility to obtain more high quality image (near to RAW)
- drasticaly lowering data size

Image decoding

JP4 format can be easy manipulated by Matlab
JP4 image

1. Read image

I=imread('hdr02.jp4'); %read JP4 file like JPEG
I=I(:,:,1);            %strip color data
2. Remove block grouping
Bayer CFA encoded image
II=deblock16x16(I);    %deblock image
%file deblock16x16.m
function y=deblock16x16(I)
y0=uint8(zeros(size(I)));
for x=1:16:size(I,1)
  for y=1:16:size(I,2)
    blk16=I(x:x+15,y:y+15);
      for dx=0:7
        for dy=0:7
          y0(x+2*dx  ,y+2*dy)   = blk16(dx+1,dy+1);
          y0(x+2*dx+1,y+2*dy)   = blk16(dx+9,dy+1);
          y0(x+2*dx  ,y+2*dy+1) = blk16(dx+1,dy+9);
          y0(x+2*dx+1,y+2*dy+1) = blk16(dx+9,dy+9);
        end
      end
    end
  end
y=y0;
2. Demosaic image (Decode from Bayer CFA (Color Filter Array) encoded image)
Decoded image
J=demosaic(III,'gbrg');

3. Show image

imshow(J);

Stream decoding

JP4 stream can be decoded by mplayer. Use this patch for glue libdc1394 and mplayer video filter frontend.

Debayer (Demosaic) algorithm variants provided by libdc1394:
- Nearest Neighbor
- Simple AVT
- Bilinear
- HQLinear
- Downsample
- Edge Sense II
- VNG
- AHD
- Linear
- fast Linear