beacon_aug/external/textflow/effects.py
def color_text(self, text_arr, bg_arr, rand=True, color=None):
        """
        Decide on a color for the text:
            - could be some other random image.
            - could be a color based on the background.
                this color is sampled from a dictionary built
                from text-word images' colors. The VALUE channel
                is randomized.
        """
        if color is not None:
            fg_col = color
        else:
            fg_col, bg_col = self.font_color.sample_from_data(bg_arr, rand=rand)
            bg_mean = np.median(bg_arr, axis=0)
            thres = 1800
            # print(np.linalg.norm(fg_col - bg_mean))
            if np.linalg.norm(fg_col - bg_mean) < thres:
                fg_col = self.font_color.complement(fg_col)

        return fg_col

        Decide on a color for the text:
            - could be some other random image.
            - could be a color based on the background.
                this color is sampled from a dictionary built
                from text-word images' colors. The VALUE channel
                is randomized.
        
Decide on a color for the text:
could be some other random image.
could be a color based on the background.
this color is sampled from a dictionary built
from text-word images' colors. The VALUE channel
is randomized.
Decide on a color for the text : could be some other random image . could be a color based on the background . this color is sampled from a dictionary built from text - word images ' colors . The VALUE channel is randomized .
def color_text(self, text_arr, bg_arr, rand=True, color=None):
        if color is not None:
            fg_col = color
        else:
            fg_col, bg_col = self.font_color.sample_from_data(bg_arr, rand=rand)
            bg_mean = np.median(bg_arr, axis=0)
            thres = 1800
            if np.linalg.norm(fg_col - bg_mean) < thres:
                fg_col = self.font_color.complement(fg_col)
        return fg_col
def color_text ( self , text_arr , bg_arr , rand = True , color = None ) : if color is not None : fg_col = color else : fg_col , bg_col = self . font_color . sample_from_data ( bg_arr , rand = rand ) bg_mean = np . median ( bg_arr , axis = 0 ) thres = 1800 if np . linalg . norm ( fg_col - bg_mean ) < thres : fg_col = self . font_color . complement ( fg_col ) return fg_col
Decide on a color for the text:
 could be some other random image.
Decide on a color for the text : could be some other random image .
"""
        Decide on a color for the text:
            - could be some other random image.
            - could be a color based on the background.
                this color is sampled from a dictionary built
                from text-word images' colors. The VALUE channel
                is randomized.
        """ # print(np.linalg.norm(fg_col - bg_mean))
self
text_arr
bg_arr
rand
color