예제 #1
0
    def blend_axis2_graph(self):

        prev_slice=self.aff_graph[:,:,:,int(self.current_loc[2,0]-self.overlap_increment[2]):int(self.current_loc[2,0]-self.overlap_increment[2]+self.shape[2])]

        blended_slice=blend.blend(prev_slice,self.buffer1,"2+",self.overlap,self.blend_fac)

        self.aff_graph[:,:,:,int(self.current_loc[2,0]-self.overlap_increment[2]):int(self.current_loc[2,0]-self.overlap_increment[2]+np.shape(blended_slice)[3])]=blended_slice
예제 #2
0
def color_of(str):
    if len(str) == 1:
        return COLOR_MAP[str]
    else:
        return blend({
            COLOR_MAP[letter]: count
            for letter, count in Counter(str).items() if letter in COLOR_MAP
        })
예제 #3
0
    def blend_axis1_buf(self):

        #in output axis 0 is verticle , axis 1 is hor ect

        #blends content of axis0 buffer with prev slice of axis1 buffer and puts in axis1 buffer
        prev_slice=self.buffer1[:,:,int(self.current_loc[1,0]-self.overlap_increment[1]):int(self.current_loc[1,0]-self.overlap_increment[1]+self.shape[1]),:]

        blended_slice=blend.blend(prev_slice,self.buffer0,"1+",self.overlap,self.blend_fac)

        self.buffer1[:,:,int(self.current_loc[1,0]-self.overlap_increment[1]):int(self.current_loc[1,0]-self.overlap_increment[1]+np.shape(blended_slice)[2]),:]=blended_slice
예제 #4
0
 def __add__(self, other):
     blend_ratio = {self.color: self.weight}
     if type(other) is ColorWord:
         new_word = self.word + other.word
         blend_ratio.update({other.color: other.weight})
     elif isinstance(other, basestring):
         new_word = self.word + other
         blend_ratio.update({color_of(other): weight_of(other)})
     else:
         raise TypeError()
     return ColorWord(new_word, blend(blend_ratio))
예제 #5
0
    def blend_axis0_buf(self):
        # blends current slice with preivous slice on axis0

        ##Go back one overlap increment to find start      ##take start and add the shape to it
        prev_slice = self.buffer0[:,
                     int(self.current_loc[0, 0] -self.overlap_increment[0]):int(self.current_loc[0, 0] - self.overlap_increment[0]+self.shape[0]),
                     0:self.shape[1],
                     0:self.shape[2]]


        blended_slice = blend.blend(prev_slice, self.aff_block, "0+", self.overlap, self.blend_fac)


        self.buffer0[:,
            int(self.current_loc[0, 0] - self.overlap_increment[0]):int(self.current_loc[0, 0] - self.overlap_increment[0] + np.shape(blended_slice)[1]),
            0:int(self.shape[1]),
            0:int(self.shape[2])] = blended_slice
예제 #6
0
import blender
import numpy as np

all_ones = np.ones((3, 20, 20, 20))

all_zeros = np.zeros((3, 20, 20, 20))

directions = ["z+", "z-", "x+", "x-", "y+", "y-"]

for dir in directions:

    print("testing " + dir + " direction...")

    blended_ones = blender.blend(all_ones, all_ones, dir, .5)

    assert (blended_ones == 1
            ).all(), "BLENDING OF TWO ALL 1 ARRAYS CONTAINS NON 1 VALUE"
    print("     ALL ONES PASSED")

    blended_zeros = blender.blend(all_zeros, all_zeros, dir, .1)

    assert (blended_zeros == 0
            ).all(), "BLENDING OF TWO ALL 0 ARRAYS CONTAINS NON 0 VALUE"
    print("     ALL ZEROS PASSED")

    if (dir == "z+" or dir == "z-"):

        assert (np.shape(blended_ones) == (
            3, 30, 20, 20)), "BLENDING SIZE IS NOT ACCURATE IN Z, IS %s" % (
                np.shape(blended_ones), ) + "INSTEAD OF %S" % (
                    (3, 30, 20, 20), )