\doxysection{main\+\_\+alpha\+\_\+blender.\+Main\+Alpha\+Blender Class Reference}
\hypertarget{classmain__alpha__blender_1_1_main_alpha_blender}{}\label{classmain__alpha__blender_1_1_main_alpha_blender}\index{main\_alpha\_blender.MainAlphaBlender@{main\_alpha\_blender.MainAlphaBlender}}
Inheritance diagram for main\+\_\+alpha\+\_\+blender.\+Main\+Alpha\+Blender\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classmain__alpha__blender_1_1_main_alpha_blender}
\end{center}
\end{figure}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classmain__alpha__blender_1_1_main_alpha_blender_adfe34758b62684144359b305f5969c5d}{\+\_\+\+\_\+init\+\_\+\+\_\+}} (self)
\item 
\mbox{\hyperlink{classmain__alpha__blender_1_1_main_alpha_blender_a1889e997e38dfc87f04ff3583e5973bf}{run}} (self)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
\begin{DoxyVerb}@brief Main controller class for executing the gamma-corrected alpha-blending pipeline.
@details
This class performs an end-to-end pipeline:
  - Reads configuration values (input image path, blending side, physical setup, gamma).
  - Loads a PNG image (ensuring BGRA so alpha can be modified safely).
  - Computes the overlap width in pixels based on the physical projector setup.
  - Builds an alpha mask curve (linear ramp) for the overlap region.
  - Applies gamma correction to the mask curve.
  - Multiplies the image alpha channel by the mask in the overlap region.
  - Saves a new PNG with adjusted transparency.
\end{DoxyVerb}
 

\doxysubsection{Constructor \& Destructor Documentation}
\Hypertarget{classmain__alpha__blender_1_1_main_alpha_blender_adfe34758b62684144359b305f5969c5d}\index{main\_alpha\_blender.MainAlphaBlender@{main\_alpha\_blender.MainAlphaBlender}!\_\_init\_\_@{\_\_init\_\_}}
\index{\_\_init\_\_@{\_\_init\_\_}!main\_alpha\_blender.MainAlphaBlender@{main\_alpha\_blender.MainAlphaBlender}}
\doxysubsubsection{\texorpdfstring{\_\_init\_\_()}{\_\_init\_\_()}}
{\footnotesize\ttfamily \label{classmain__alpha__blender_1_1_main_alpha_blender_adfe34758b62684144359b305f5969c5d} 
main\+\_\+alpha\+\_\+blender.\+Main\+Alpha\+Blender.\+\_\+\+\_\+init\+\_\+\+\_\+ (\begin{DoxyParamCaption}\item[{}]{self}{}\end{DoxyParamCaption})}

\begin{DoxyVerb}@brief Constructor for MainAlphaBlender.
@details
Initializes a ConfigReader instance to retrieve blending parameters.
The config reader is expected to provide:
  - input image filename
  - which side of the overlap this projector corresponds to ("left" or "right")
  - physical projected image width
  - physical distance between two projectors
  - gamma value used for correction
@see config_reader.py
\end{DoxyVerb}
 

\doxysubsection{Member Function Documentation}
\Hypertarget{classmain__alpha__blender_1_1_main_alpha_blender_a1889e997e38dfc87f04ff3583e5973bf}\index{main\_alpha\_blender.MainAlphaBlender@{main\_alpha\_blender.MainAlphaBlender}!run@{run}}
\index{run@{run}!main\_alpha\_blender.MainAlphaBlender@{main\_alpha\_blender.MainAlphaBlender}}
\doxysubsubsection{\texorpdfstring{run()}{run()}}
{\footnotesize\ttfamily \label{classmain__alpha__blender_1_1_main_alpha_blender_a1889e997e38dfc87f04ff3583e5973bf} 
main\+\_\+alpha\+\_\+blender.\+Main\+Alpha\+Blender.\+run (\begin{DoxyParamCaption}\item[{}]{self}{}\end{DoxyParamCaption})}

\begin{DoxyVerb}@brief Executes the full alpha blending process (gamma corrected).
@details
steps:
1) Load configuration parameters:
   - image_name: input image file (ideally PNG with alpha)
   - side: "left" or "right" indicating which projector image this is
   - proj_width_phys: physical width of one projected image
   - dist_phys: physical distance between projector centers (or image origins depending on setup)
   - gamma: projector gamma value (> 0)

2) Load image using OpenCV:
   - cv2.IMREAD_UNCHANGED preserves alpha if present.
   - If the image is BGR (3 channels), it is converted to BGRA (4 channels)
     so we can write an alpha mask safely.

3) Compute overlap ratio and overlap width (pixels):
   - overlap_ratio = 1 - (dist_phys / proj_width_phys)
     Example:
       dist_phys == proj_width_phys  -> overlap_ratio = 0 (no overlap)
       dist_phys <  proj_width_phys  -> overlap_ratio > 0 (overlap exists)
   - overlap_pixels = int(width * overlap_ratio)

4) Generate a base linear ramp across the overlap region:
   - linear_ramp is always 0 → 1 across overlap_pixels.
   - For the left image: fade out (1 → 0) in the overlap.
   - For the right image: fade in  (0 → 1) in the overlap.

5) Gamma correction:
   - Projector brightness response is non-linear.
   - We compensate by applying:
       mask_curve = base_curve^(1/gamma)
   - This helps produce a visually smoother blend once projected.

6) Apply the mask to the alpha channel:
   - Convert alpha to float in [0, 1].
   - Expand mask_curve vertically to match image height.
   - Multiply only the overlap region of alpha.

7) Save output image:
   - Writes output_left.png or output_right.png depending on side.

Error / early-exit conditions:
- If the input image cannot be loaded, the process stops.
- If overlap_ratio <= 0, there is no overlap (or invalid physical config), so it stops.
- If side is not "left" or "right", it stops.

@return This returns None.
@see config_reader.py
\end{DoxyVerb}
 

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/\+Users/kaungzinthu/\+Desktop/projectpbl2/\mbox{\hyperlink{main__alpha__blender_8py}{main\+\_\+alpha\+\_\+blender.\+py}}\end{DoxyCompactItemize}
