SlideShare a Scribd company logo
2D Block Scaling Control Software
Shereef Shehata
Top Level Function for Scaling and rotation
• void Block_scaler_rot (regfield_struc *regfield_ptr, unsigned char
**A_in, unsigned char **R_in, unsigned char **G_in, unsigned char
**B_in, unsigned char **A_out, unsigned char **R_out, unsigned char
**G_out, unsigned char **B_out)
• This function is the top Level scale and rotate function. It is
input is the input image to be scaled and rotated. The output is
the scaled and rotated image.
Block_scaler_rot functional dependencies
Horizontal Scaler Control
• void horiz_scaler_control (long *H_in_Block_St_col, long
*H_in_Block_End_col, long *H_out_Block_St_col, long
*H_out_Block_End_col, int srcW, int tarW, int H_scan_dir, int
Scale_factor_h, int Inv_scale_h, int H_no_blocks)
• This function will determine the starting/ending column for each block in the
horizontal direction H_in_Block_St_col, H_in_Block_End_col for the input
image to be scaled.
• This function will also determine the starting/ending column for each block
in the horizontal direction H_out_Block_End_col, H_out_Block_End_col for
the output scaled image.
Block-scaling control (The notion of pixel index does not depend on the
direction of scan)
tarH
srcH
srcW tarW(H =1,V=1)
(H =1,V=tarH)
(H =tarW,V=1)
(H =1,V=srcH) (H =srcW,V=srcH)
(H =tarW,V=tarH)
(H =1,V=1) (H =srcW,V=1)
5
Block-scaling control (Vertical scan down, Horizontal Scan right)
tarW
tarH
srcH
srcW
6
Block-scaling control (Vertical scan down, Horizontal scan right)
tarH
tarW
srcH
srcW
7
Block-scaling control (Vertical scan down, Horizontal scan left)
tarW
tarH
srcH
srcW
8
Block-scaling control (Vertical scan down, Horizontal scan left)
tarH
tarW
srcH
srcW
9
Block-scaling control (Vertical scan up, Horizontal scan left)
tarW
tarH
srcH
srcW
10
Block-scaling control (Vertical scan up, Horizontal scan left)
tarH
tarW
srcH
srcW
11
Block-scaling control (Vertical scan up, Horizontal scan right)
tarW
tarH
srcH
srcW
12
Block-scaling control (Vertical scan up, Horizontal scan right)
tarH
tarW
srcH
srcW
13
Vertical block-scaling control
out_Blk_sz_v = 32;
V_no_blocks = ceil(tarH ./out_Blk_sz_v)
Determine the vertical number of blocks
Initialize the first row of the first output vertical block based
On the direction of scan
14
Vertical Block-scaling control (Vertical number of blocks is the same in
the output and input)
Vert_blox_index =1
Vert_blox_index =
V_no_blocks
Vert_blox_index =1
15
Vertical block-scaling control
if (V_scan_dir == 1)
% Vertical scan is Down
V_in_Block_St_row(1) = 1;
V_out_Block_St_row(1) = 1;
else
% Vertical scan is Up
V_in_Block_St_row(1) = srcH;
V_out_Block_St_row(1) = tarH;
end
Initialize the Start row of the first input vertical block based
on the direction of scan
While Scaning target image pixel rows
According to the direction of scan
1<= tar_row<= (tar_H)
Initialize the Start row of the first output vertical block based
On the direction of scan
16
Vertical Block-scaling control (Starting vertical row of the first vertical
block for the input and output)
V_in_Block_St_row(1)
V_in_Block_St_row(1) = tarH
V_out_Block_St_row(1)
V_in_Block_St_row(1) = srcH
17
Vertical block-scaling control (Determine the output vertical block
boundary)
while (( V_scan_dir ==1) && tar_row <= tarH || (( V_scan_dir ==2) && tar_row >= 1 ) )
% At boundary row of an output vertical block
if ( ((V_scan_dir == 1) && (rem(tar_row,out_Blk_sz_v) == 0 )) || ...
((V_scan_dir == 2) && ( rem(((tarH-tar_row)+1), out_Blk_sz_v) == 0 )) )
While Scaning target image pixel rows
According to the direction of scan
1<= tar_row<= (tar_H)
At each vertical block boundary
of the target image
Compute the vertical block index
18
Vertical Block-scaling control (Determine the output vertical block
boundary)
((V_scan_dir == 1) && (rem(tar_row,out_Blk_sz_v) == 0 ))
((V_scan_dir == 2) && ( rem(((tarH-tar_row)+1),
out_Blk_sz_v) == 0 ))
19
Vertical block-scaling control (Compute the current vertical block index
depending on the direction of scan)
% compute the current vertical block index
% Vertically Down
if (V_scan_dir == 1)
Vert_Block_Index = floor(tar_row./out_Blk_sz_v);
else
% Vertically Up
Vert_Block_Index = floor(((tarH-tar_row)+1) ./ out_Blk_sz_v);
end
At each vertical block boundary
of the target image do:
Compute the vertical block index
20
Vertical Block-scaling control (Compute the output vertical block index)
Vert_Block_Index = 1
Vert_Block_Index = V_no_blocks-1
Vert_Block_Index = V_no_blocks
Vert_Block_Index = V_no_blocks
Vert_Block_Index = V_no_blocks-1
Vert_Block_Index = 1
21
Vertical block-scaling control (Compute the end row of the output
vertical block)
% compute the block-end boundary of the current output vertical block
V_out_Block_End_row(Vert_Block_Index) = tar_row;
Compute the vertical block index
Compute the end row of the current output vertical block
22
Vertical block-scaling control (Compute the end row of the output
vertical block)
V_out_Block_End_row(1)
V_out_Block_End_row(V_no_blocks-1)
V_out_Block_End_row(V_no_blocks)=tarH
V_out_Block_End_row(V_no_blocks)=1
V_out_Block_End_row(V_no_blocks-1)
V_out_Block_End_row(1)
23
Vertical block-scaling control (Compute the end row of the current input
vertical block, for vertical down scan)
if(V_scan_dir ==1)
if(Inv_scale_v >= 1)
% down scaling
V_in_Block_End_row(Vert_Block_Index) = ceil(tar_row * Inv_scale_v);
else
V_in_Block_End_row(Vert_Block_Index) = ceil(tar_row * Inv_scale_v)+1;
end
if ( V_in_Block_End_row(Vert_Block_Index) > srcH)
V_in_Block_End_row(Vert_Block_Index) = srcH;
end
Compute the end row of the current output vertical block
compute the block-end boundary of the current input
vertical block (Vertical down scan)
24
Vertical block-scaling control (Compute the end row of the current input
vertical block, for vertical down scan) Down-Scaling
V_in_Block_End_row(1)
V_in_Block_End_row(2)
V_in_Block_End_row(V_no_blocks-1)
V_in_Block_End_row(V_no_blocks)
25
Vertical block-scaling control (Compute the end row of the current input
vertical block, for vertical down scan) Up-Scaling
V_in_Block_End_row(1)
V_in_Block_End_row(2)
V_in_Block_End_row(V_no_blocks-1)
V_in_Block_End_row(V_no_blocks)
26
Vertical block-scaling control (Compute the end row of the current input
vertical block, for vertical up scan)
else
% Vertical Up Scan
if(Inv_scale_v >= 1)
% down scaling
V_in_Block_End_row(Vert_Block_Index) = srcH - (ceil( ((tarH-tar_row)+1) * Inv_scale_v) ) + 1;
else
V_in_Block_End_row(Vert_Block_Index) = srcH - (ceil( ((tarH-tar_row)+1) * Inv_scale_v) ) ;
end
if ( V_in_Block_End_row(Vert_Block_Index) < 1)
V_in_Block_End_row(Vert_Block_Index) = 1;
end
end
Compute the end row of the current output vertical block
compute the block-end boundary of the current input
vertical block (Vertical up scan)
27
Vertical block-scaling control (Compute the end row of the current input
vertical block, for vertical up scan) Down-Scaling
V_in_Block_End_row(1)
V_in_Block_End_row(2)
V_in_Block_End_row(V_no_blocks-1)
V_in_Block_End_row(V_no_blocks)
28
Vertical block-scaling control (Compute the end row of the current input
vertical block, for vertical up scan) Up-Scaling
V_in_Block_End_row(1)
V_in_Block_End_row(2)
V_in_Block_End_row(V_no_blocks-1)
V_in_Block_End_row(V_no_blocks)
29
Vertical block-scaling control (Compute the start row of the next output
vertical block)
if (V_scan_dir == 1)
% Vertically Down
V_out_Block_St_row(Vert_Block_Index+1) = V_out_Block_End_row(Vert_Block_Index)+1;
if (V_out_Block_St_row(Vert_Block_Index+1) > tarH)
V_out_Block_St_row(Vert_Block_Index+1) = tarH;
end
else
% Vertically Up
V_out_Block_St_row(Vert_Block_Index+1) = V_out_Block_End_row(Vert_Block_Index)-1;
if (V_out_Block_St_row(Vert_Block_Index+1) < 1)
V_out_Block_St_row(Vert_Block_Index+1) = 1;
end
end
compute the block-end boundary of the current input
vertical block (Vertical down/up scan)
compute the block-start boundary of the next output
vertical block (Vertical down/up scan)
30
Vertical block-scaling control (Compute the start row of the output
vertical block)
V_out_Block_St_row(1) = 1
V_out_Block_St_row(V_no_blocks-1)
V_out_Block_St_row(V_no_blocks)
V_out_Block_St_row(V_no_blocks)
V_out_Block_St_row(V_no_blocks-1)
V_out_Block_St_row(1) = tarH
31
Vertical block-scaling control (Compute the start row of the next input
vertical block, for vertical down scan)
if(V_scan_dir ==1)
if(Inv_scale_v >= 1)
% down scaling
V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index);
else
% Up scaling
V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index)-1;
end
if (V_in_Block_St_row(Vert_Block_Index+1) > srcH)
V_in_Block_St_row(Vert_Block_Index+1) = srcH;
end
compute the block-start boundary of the current output
vertical block (Vertical down/up scan)
compute the block-start boundary of the next input
vertical block (Vertical down scan)
32
Vertical block-scaling control (Compute the start row of the input
vertical block, for vertical down scan) Down-Scaling
V_in_Block_St_row(1)
V_in_Block_St_row(2)
V_in_Block_St_row(V_no_blocks-1)
V_in_Block_St_row(V_no_blocks)
33
Vertical block-scaling control (Compute the start row of the input
vertical block, for vertical down scan) Up-Scaling
V_in_Block_St_row(1)
V_in_Block_St_row(2)
V_in_Block_St_row(V_no_blocks-1)
V_in_Block_St_row(V_no_blocks)
34
Vertical block-scaling control (Compute the start row of the next input
vertical block, for vertical up scan)
else
if (Inv_scale_v >= 1)
% down scale
V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index);
else
% compute the block-start boundary of the current input vertical block
V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index)+1;
end
if (V_in_Block_St_row(Vert_Block_Index+1) < 1)
V_in_Block_St_row(Vert_Block_Index+1) = 1;
end
end
compute the block-start boundary of the current output
vertical block (Vertical down/up scan)
compute the block-start boundary of the next input
vertical block (Vertical up scan)
35
Vertical block-scaling control (Compute the start row of the input
vertical block, for vertical up scan) Down-Scaling
V_in_Block_ST_row(1)
V_in_Block_St_row(2)
V_in_Block_St_row(V_no_blocks-1)
V_in_Block_St_row(V_no_blocks)
36
Vertical block-scaling control (Compute the start row of the input
vertical block, for vertical up scan) Up-Scaling
V_in_Block_End_row(1)
V_in_Block_End_row(2)
V_in_Block_End_row(V_no_blocks-1)
V_in_Block_End_row(V_no_blocks)
37
Vertical block-scaling control (Adjust the start row of the next input
vertical block, if the current input block has no vertical pixel fraction)
if (V_scan_dir == 1)
% Vertical down
if ( ( ceil(tar_row * Inv_scale_v) - (tar_row * Inv_scale_v)) == 0)
V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_St_row(Vert_Block_Index+1) + 1;
end
if (V_in_Block_St_row(Vert_Block_Index+1) > srcH)
V_in_Block_St_row(Vert_Block_Index+1) = srcH;
end
else
% Vertical Up
if ( ( (ceil( ((tarH-tar_row)+1) * Inv_scale_v) ) - ( ((tarH-tar_row)+1) * Inv_scale_v) ) == 0)
V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_St_row(Vert_Block_Index+1) - 1;
end
if (V_in_Block_St_row(Vert_Block_Index+1) < 1)
V_in_Block_St_row(Vert_Block_Index+1) = 1;
end
end
compute the block-start boundary of the current input
vertical block (Vertical down/up scan)
Adjust the block-start boundary of the current input
vertical block if the real current vertical block
ended on a pixel boundary (Vertical down/up scan)
38
Vertical block-scaling control (Adjust the start row of the next input vertical block, if the
current input block has no vertical pixel fraction) Vertical down scan, Down-Scaling
V_in_Block_St_row(1)
V_in_Block_St_row(2)
V_in_Block_St_row(V_no_blocks-1)
V_in_Block_St_row(V_no_blocks)
39
Vertical block-scaling control (Adjust the start row of the next input vertical block, if the
current input block has no vertical pixel fraction) Vertical down scan, Up-Scaling
V_in_Block_St_row(1)
V_in_Block_St_row(2)
V_in_Block_St_row(V_no_blocks-1)
V_in_Block_St_row(V_no_blocks)
40
Vertical block-scaling control (Adjust the start row of the next input vertical block, if the
current input block has no vertical pixel fraction) Vertical up scan, Down-Scaling
V_in_Block_ST_row(1)
V_in_Block_St_row(2)
V_in_Block_St_row(V_no_blocks-1)
V_in_Block_St_row(V_no_blocks)
41
Vertical block-scaling control (Adjust the start row of the next input vertical block, if the
current input block has no vertical pixel fraction) Vertical up scan, Up-Scaling
V_in_Block_ST_row(1)
V_in_Block_St_row(2)
V_in_Block_St_row(V_no_blocks-1)
V_in_Block_St_row(V_no_blocks)
42

More Related Content

Viewers also liked

Mi presentacion 1996
Mi presentacion 1996Mi presentacion 1996
Mi presentacion 1996
regi7224230782
 
2D_BitBlt_Scale
2D_BitBlt_Scale2D_BitBlt_Scale
2D_BitBlt_Scale
Shereef Shehata
 
Temporal_video_noise_reduction
Temporal_video_noise_reductionTemporal_video_noise_reduction
Temporal_video_noise_reduction
Shereef Shehata
 
Cara membuat blog
Cara membuat blogCara membuat blog
Cara membuat blog
Arief Arief
 
Windows_Scaling_2X_Speedup
Windows_Scaling_2X_SpeedupWindows_Scaling_2X_Speedup
Windows_Scaling_2X_Speedup
Shereef Shehata
 
2D_BLIT_software_Blackness
2D_BLIT_software_Blackness2D_BLIT_software_Blackness
2D_BLIT_software_Blackness
Shereef Shehata
 
CIECAM02_Color_Management
CIECAM02_Color_ManagementCIECAM02_Color_Management
CIECAM02_Color_Management
Shereef Shehata
 
Architectural_Synthesis_for_DSP_Structured_Datapaths
Architectural_Synthesis_for_DSP_Structured_DatapathsArchitectural_Synthesis_for_DSP_Structured_Datapaths
Architectural_Synthesis_for_DSP_Structured_Datapaths
Shereef Shehata
 
2013 1 pta general assembly final
2013 1 pta general assembly final2013 1 pta general assembly final
2013 1 pta general assembly finalshannonwrice
 
The_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_ArchitectureThe_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_Architecture
Shereef Shehata
 
High_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAs
High_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAsHigh_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAs
High_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAs
Shereef Shehata
 
Shereef_MP3_decoder
Shereef_MP3_decoderShereef_MP3_decoder
Shereef_MP3_decoder
Shereef Shehata
 
Inertial_Sensors
Inertial_SensorsInertial_Sensors
Inertial_Sensors
Shereef Shehata
 
Nhom d water chiller
Nhom d  water chillerNhom d  water chiller
Nhom d water chillerHuy Cường
 
Gyroscope_sensors
Gyroscope_sensorsGyroscope_sensors
Gyroscope_sensors
Shereef Shehata
 

Viewers also liked (15)

Mi presentacion 1996
Mi presentacion 1996Mi presentacion 1996
Mi presentacion 1996
 
2D_BitBlt_Scale
2D_BitBlt_Scale2D_BitBlt_Scale
2D_BitBlt_Scale
 
Temporal_video_noise_reduction
Temporal_video_noise_reductionTemporal_video_noise_reduction
Temporal_video_noise_reduction
 
Cara membuat blog
Cara membuat blogCara membuat blog
Cara membuat blog
 
Windows_Scaling_2X_Speedup
Windows_Scaling_2X_SpeedupWindows_Scaling_2X_Speedup
Windows_Scaling_2X_Speedup
 
2D_BLIT_software_Blackness
2D_BLIT_software_Blackness2D_BLIT_software_Blackness
2D_BLIT_software_Blackness
 
CIECAM02_Color_Management
CIECAM02_Color_ManagementCIECAM02_Color_Management
CIECAM02_Color_Management
 
Architectural_Synthesis_for_DSP_Structured_Datapaths
Architectural_Synthesis_for_DSP_Structured_DatapathsArchitectural_Synthesis_for_DSP_Structured_Datapaths
Architectural_Synthesis_for_DSP_Structured_Datapaths
 
2013 1 pta general assembly final
2013 1 pta general assembly final2013 1 pta general assembly final
2013 1 pta general assembly final
 
The_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_ArchitectureThe_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_Architecture
 
High_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAs
High_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAsHigh_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAs
High_Level_Synthesis_of_DSP_Archiectures_Targeting_FPGAs
 
Shereef_MP3_decoder
Shereef_MP3_decoderShereef_MP3_decoder
Shereef_MP3_decoder
 
Inertial_Sensors
Inertial_SensorsInertial_Sensors
Inertial_Sensors
 
Nhom d water chiller
Nhom d  water chillerNhom d  water chiller
Nhom d water chiller
 
Gyroscope_sensors
Gyroscope_sensorsGyroscope_sensors
Gyroscope_sensors
 

Similar to 2D_block_scaling_Software

Cse 402 offline b2
Cse 402 offline b2Cse 402 offline b2
Cse 402 offline b2
sujoyhnkc
 
OpenVX 1.1 Reference Guide
OpenVX 1.1 Reference GuideOpenVX 1.1 Reference Guide
OpenVX 1.1 Reference Guide
The Khronos Group Inc.
 
OpenVX 1.2 Reference Guide
OpenVX 1.2 Reference GuideOpenVX 1.2 Reference Guide
OpenVX 1.2 Reference Guide
The Khronos Group Inc.
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
Amol Gaikwad
 
gate level modeling
gate level modelinggate level modeling
gate level modeling
VandanaBR2
 
UNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdfUNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdf
VivekKumar148171
 
lecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.pptlecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.ppt
ssuser2ae35a
 
Layout manager
Layout managerLayout manager
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
Balamurugan M
 
OpenVX 1.3 Reference Guide
OpenVX 1.3 Reference GuideOpenVX 1.3 Reference Guide
OpenVX 1.3 Reference Guide
The Khronos Group Inc.
 

Similar to 2D_block_scaling_Software (10)

Cse 402 offline b2
Cse 402 offline b2Cse 402 offline b2
Cse 402 offline b2
 
OpenVX 1.1 Reference Guide
OpenVX 1.1 Reference GuideOpenVX 1.1 Reference Guide
OpenVX 1.1 Reference Guide
 
OpenVX 1.2 Reference Guide
OpenVX 1.2 Reference GuideOpenVX 1.2 Reference Guide
OpenVX 1.2 Reference Guide
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
 
gate level modeling
gate level modelinggate level modeling
gate level modeling
 
UNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdfUNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdf
 
lecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.pptlecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.ppt
 
Layout manager
Layout managerLayout manager
Layout manager
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
 
OpenVX 1.3 Reference Guide
OpenVX 1.3 Reference GuideOpenVX 1.3 Reference Guide
OpenVX 1.3 Reference Guide
 

2D_block_scaling_Software

  • 1. 2D Block Scaling Control Software Shereef Shehata
  • 2. Top Level Function for Scaling and rotation • void Block_scaler_rot (regfield_struc *regfield_ptr, unsigned char **A_in, unsigned char **R_in, unsigned char **G_in, unsigned char **B_in, unsigned char **A_out, unsigned char **R_out, unsigned char **G_out, unsigned char **B_out) • This function is the top Level scale and rotate function. It is input is the input image to be scaled and rotated. The output is the scaled and rotated image.
  • 4. Horizontal Scaler Control • void horiz_scaler_control (long *H_in_Block_St_col, long *H_in_Block_End_col, long *H_out_Block_St_col, long *H_out_Block_End_col, int srcW, int tarW, int H_scan_dir, int Scale_factor_h, int Inv_scale_h, int H_no_blocks) • This function will determine the starting/ending column for each block in the horizontal direction H_in_Block_St_col, H_in_Block_End_col for the input image to be scaled. • This function will also determine the starting/ending column for each block in the horizontal direction H_out_Block_End_col, H_out_Block_End_col for the output scaled image.
  • 5. Block-scaling control (The notion of pixel index does not depend on the direction of scan) tarH srcH srcW tarW(H =1,V=1) (H =1,V=tarH) (H =tarW,V=1) (H =1,V=srcH) (H =srcW,V=srcH) (H =tarW,V=tarH) (H =1,V=1) (H =srcW,V=1) 5
  • 6. Block-scaling control (Vertical scan down, Horizontal Scan right) tarW tarH srcH srcW 6
  • 7. Block-scaling control (Vertical scan down, Horizontal scan right) tarH tarW srcH srcW 7
  • 8. Block-scaling control (Vertical scan down, Horizontal scan left) tarW tarH srcH srcW 8
  • 9. Block-scaling control (Vertical scan down, Horizontal scan left) tarH tarW srcH srcW 9
  • 10. Block-scaling control (Vertical scan up, Horizontal scan left) tarW tarH srcH srcW 10
  • 11. Block-scaling control (Vertical scan up, Horizontal scan left) tarH tarW srcH srcW 11
  • 12. Block-scaling control (Vertical scan up, Horizontal scan right) tarW tarH srcH srcW 12
  • 13. Block-scaling control (Vertical scan up, Horizontal scan right) tarH tarW srcH srcW 13
  • 14. Vertical block-scaling control out_Blk_sz_v = 32; V_no_blocks = ceil(tarH ./out_Blk_sz_v) Determine the vertical number of blocks Initialize the first row of the first output vertical block based On the direction of scan 14
  • 15. Vertical Block-scaling control (Vertical number of blocks is the same in the output and input) Vert_blox_index =1 Vert_blox_index = V_no_blocks Vert_blox_index =1 15
  • 16. Vertical block-scaling control if (V_scan_dir == 1) % Vertical scan is Down V_in_Block_St_row(1) = 1; V_out_Block_St_row(1) = 1; else % Vertical scan is Up V_in_Block_St_row(1) = srcH; V_out_Block_St_row(1) = tarH; end Initialize the Start row of the first input vertical block based on the direction of scan While Scaning target image pixel rows According to the direction of scan 1<= tar_row<= (tar_H) Initialize the Start row of the first output vertical block based On the direction of scan 16
  • 17. Vertical Block-scaling control (Starting vertical row of the first vertical block for the input and output) V_in_Block_St_row(1) V_in_Block_St_row(1) = tarH V_out_Block_St_row(1) V_in_Block_St_row(1) = srcH 17
  • 18. Vertical block-scaling control (Determine the output vertical block boundary) while (( V_scan_dir ==1) && tar_row <= tarH || (( V_scan_dir ==2) && tar_row >= 1 ) ) % At boundary row of an output vertical block if ( ((V_scan_dir == 1) && (rem(tar_row,out_Blk_sz_v) == 0 )) || ... ((V_scan_dir == 2) && ( rem(((tarH-tar_row)+1), out_Blk_sz_v) == 0 )) ) While Scaning target image pixel rows According to the direction of scan 1<= tar_row<= (tar_H) At each vertical block boundary of the target image Compute the vertical block index 18
  • 19. Vertical Block-scaling control (Determine the output vertical block boundary) ((V_scan_dir == 1) && (rem(tar_row,out_Blk_sz_v) == 0 )) ((V_scan_dir == 2) && ( rem(((tarH-tar_row)+1), out_Blk_sz_v) == 0 )) 19
  • 20. Vertical block-scaling control (Compute the current vertical block index depending on the direction of scan) % compute the current vertical block index % Vertically Down if (V_scan_dir == 1) Vert_Block_Index = floor(tar_row./out_Blk_sz_v); else % Vertically Up Vert_Block_Index = floor(((tarH-tar_row)+1) ./ out_Blk_sz_v); end At each vertical block boundary of the target image do: Compute the vertical block index 20
  • 21. Vertical Block-scaling control (Compute the output vertical block index) Vert_Block_Index = 1 Vert_Block_Index = V_no_blocks-1 Vert_Block_Index = V_no_blocks Vert_Block_Index = V_no_blocks Vert_Block_Index = V_no_blocks-1 Vert_Block_Index = 1 21
  • 22. Vertical block-scaling control (Compute the end row of the output vertical block) % compute the block-end boundary of the current output vertical block V_out_Block_End_row(Vert_Block_Index) = tar_row; Compute the vertical block index Compute the end row of the current output vertical block 22
  • 23. Vertical block-scaling control (Compute the end row of the output vertical block) V_out_Block_End_row(1) V_out_Block_End_row(V_no_blocks-1) V_out_Block_End_row(V_no_blocks)=tarH V_out_Block_End_row(V_no_blocks)=1 V_out_Block_End_row(V_no_blocks-1) V_out_Block_End_row(1) 23
  • 24. Vertical block-scaling control (Compute the end row of the current input vertical block, for vertical down scan) if(V_scan_dir ==1) if(Inv_scale_v >= 1) % down scaling V_in_Block_End_row(Vert_Block_Index) = ceil(tar_row * Inv_scale_v); else V_in_Block_End_row(Vert_Block_Index) = ceil(tar_row * Inv_scale_v)+1; end if ( V_in_Block_End_row(Vert_Block_Index) > srcH) V_in_Block_End_row(Vert_Block_Index) = srcH; end Compute the end row of the current output vertical block compute the block-end boundary of the current input vertical block (Vertical down scan) 24
  • 25. Vertical block-scaling control (Compute the end row of the current input vertical block, for vertical down scan) Down-Scaling V_in_Block_End_row(1) V_in_Block_End_row(2) V_in_Block_End_row(V_no_blocks-1) V_in_Block_End_row(V_no_blocks) 25
  • 26. Vertical block-scaling control (Compute the end row of the current input vertical block, for vertical down scan) Up-Scaling V_in_Block_End_row(1) V_in_Block_End_row(2) V_in_Block_End_row(V_no_blocks-1) V_in_Block_End_row(V_no_blocks) 26
  • 27. Vertical block-scaling control (Compute the end row of the current input vertical block, for vertical up scan) else % Vertical Up Scan if(Inv_scale_v >= 1) % down scaling V_in_Block_End_row(Vert_Block_Index) = srcH - (ceil( ((tarH-tar_row)+1) * Inv_scale_v) ) + 1; else V_in_Block_End_row(Vert_Block_Index) = srcH - (ceil( ((tarH-tar_row)+1) * Inv_scale_v) ) ; end if ( V_in_Block_End_row(Vert_Block_Index) < 1) V_in_Block_End_row(Vert_Block_Index) = 1; end end Compute the end row of the current output vertical block compute the block-end boundary of the current input vertical block (Vertical up scan) 27
  • 28. Vertical block-scaling control (Compute the end row of the current input vertical block, for vertical up scan) Down-Scaling V_in_Block_End_row(1) V_in_Block_End_row(2) V_in_Block_End_row(V_no_blocks-1) V_in_Block_End_row(V_no_blocks) 28
  • 29. Vertical block-scaling control (Compute the end row of the current input vertical block, for vertical up scan) Up-Scaling V_in_Block_End_row(1) V_in_Block_End_row(2) V_in_Block_End_row(V_no_blocks-1) V_in_Block_End_row(V_no_blocks) 29
  • 30. Vertical block-scaling control (Compute the start row of the next output vertical block) if (V_scan_dir == 1) % Vertically Down V_out_Block_St_row(Vert_Block_Index+1) = V_out_Block_End_row(Vert_Block_Index)+1; if (V_out_Block_St_row(Vert_Block_Index+1) > tarH) V_out_Block_St_row(Vert_Block_Index+1) = tarH; end else % Vertically Up V_out_Block_St_row(Vert_Block_Index+1) = V_out_Block_End_row(Vert_Block_Index)-1; if (V_out_Block_St_row(Vert_Block_Index+1) < 1) V_out_Block_St_row(Vert_Block_Index+1) = 1; end end compute the block-end boundary of the current input vertical block (Vertical down/up scan) compute the block-start boundary of the next output vertical block (Vertical down/up scan) 30
  • 31. Vertical block-scaling control (Compute the start row of the output vertical block) V_out_Block_St_row(1) = 1 V_out_Block_St_row(V_no_blocks-1) V_out_Block_St_row(V_no_blocks) V_out_Block_St_row(V_no_blocks) V_out_Block_St_row(V_no_blocks-1) V_out_Block_St_row(1) = tarH 31
  • 32. Vertical block-scaling control (Compute the start row of the next input vertical block, for vertical down scan) if(V_scan_dir ==1) if(Inv_scale_v >= 1) % down scaling V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index); else % Up scaling V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index)-1; end if (V_in_Block_St_row(Vert_Block_Index+1) > srcH) V_in_Block_St_row(Vert_Block_Index+1) = srcH; end compute the block-start boundary of the current output vertical block (Vertical down/up scan) compute the block-start boundary of the next input vertical block (Vertical down scan) 32
  • 33. Vertical block-scaling control (Compute the start row of the input vertical block, for vertical down scan) Down-Scaling V_in_Block_St_row(1) V_in_Block_St_row(2) V_in_Block_St_row(V_no_blocks-1) V_in_Block_St_row(V_no_blocks) 33
  • 34. Vertical block-scaling control (Compute the start row of the input vertical block, for vertical down scan) Up-Scaling V_in_Block_St_row(1) V_in_Block_St_row(2) V_in_Block_St_row(V_no_blocks-1) V_in_Block_St_row(V_no_blocks) 34
  • 35. Vertical block-scaling control (Compute the start row of the next input vertical block, for vertical up scan) else if (Inv_scale_v >= 1) % down scale V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index); else % compute the block-start boundary of the current input vertical block V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_End_row(Vert_Block_Index)+1; end if (V_in_Block_St_row(Vert_Block_Index+1) < 1) V_in_Block_St_row(Vert_Block_Index+1) = 1; end end compute the block-start boundary of the current output vertical block (Vertical down/up scan) compute the block-start boundary of the next input vertical block (Vertical up scan) 35
  • 36. Vertical block-scaling control (Compute the start row of the input vertical block, for vertical up scan) Down-Scaling V_in_Block_ST_row(1) V_in_Block_St_row(2) V_in_Block_St_row(V_no_blocks-1) V_in_Block_St_row(V_no_blocks) 36
  • 37. Vertical block-scaling control (Compute the start row of the input vertical block, for vertical up scan) Up-Scaling V_in_Block_End_row(1) V_in_Block_End_row(2) V_in_Block_End_row(V_no_blocks-1) V_in_Block_End_row(V_no_blocks) 37
  • 38. Vertical block-scaling control (Adjust the start row of the next input vertical block, if the current input block has no vertical pixel fraction) if (V_scan_dir == 1) % Vertical down if ( ( ceil(tar_row * Inv_scale_v) - (tar_row * Inv_scale_v)) == 0) V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_St_row(Vert_Block_Index+1) + 1; end if (V_in_Block_St_row(Vert_Block_Index+1) > srcH) V_in_Block_St_row(Vert_Block_Index+1) = srcH; end else % Vertical Up if ( ( (ceil( ((tarH-tar_row)+1) * Inv_scale_v) ) - ( ((tarH-tar_row)+1) * Inv_scale_v) ) == 0) V_in_Block_St_row(Vert_Block_Index+1) = V_in_Block_St_row(Vert_Block_Index+1) - 1; end if (V_in_Block_St_row(Vert_Block_Index+1) < 1) V_in_Block_St_row(Vert_Block_Index+1) = 1; end end compute the block-start boundary of the current input vertical block (Vertical down/up scan) Adjust the block-start boundary of the current input vertical block if the real current vertical block ended on a pixel boundary (Vertical down/up scan) 38
  • 39. Vertical block-scaling control (Adjust the start row of the next input vertical block, if the current input block has no vertical pixel fraction) Vertical down scan, Down-Scaling V_in_Block_St_row(1) V_in_Block_St_row(2) V_in_Block_St_row(V_no_blocks-1) V_in_Block_St_row(V_no_blocks) 39
  • 40. Vertical block-scaling control (Adjust the start row of the next input vertical block, if the current input block has no vertical pixel fraction) Vertical down scan, Up-Scaling V_in_Block_St_row(1) V_in_Block_St_row(2) V_in_Block_St_row(V_no_blocks-1) V_in_Block_St_row(V_no_blocks) 40
  • 41. Vertical block-scaling control (Adjust the start row of the next input vertical block, if the current input block has no vertical pixel fraction) Vertical up scan, Down-Scaling V_in_Block_ST_row(1) V_in_Block_St_row(2) V_in_Block_St_row(V_no_blocks-1) V_in_Block_St_row(V_no_blocks) 41
  • 42. Vertical block-scaling control (Adjust the start row of the next input vertical block, if the current input block has no vertical pixel fraction) Vertical up scan, Up-Scaling V_in_Block_ST_row(1) V_in_Block_St_row(2) V_in_Block_St_row(V_no_blocks-1) V_in_Block_St_row(V_no_blocks) 42