''' 2021-06-07 Pure abandoment, As in, The Project has been abandoned Img is a personal library, used by me as a Base Class for many image effects I do not expect to include Img in this pull. # # # Created on Nov 27, 2017 @author: Brett Paufler Copyright Brett Paufler This is basically broken, a work in progress as finished, effect not as desired from iPhone notes, for next step max wins, alternating dots of color extending latest version, which doesn't seem to work ''' from Img import images, Img import numpy as np #from itertools import permutations class ColorHighlights(Img): '''Note the extensive use of masks''' def __init__(self, file_in, **kwargs): Img.__init__(self, file_in=file_in, as_grey=False, **kwargs) def highlight(self, n): self.tag_name('highlight_%d' %n) #colors = {} r_start = self.img[:, :, 0].copy() g_start = self.img[:, :, 1].copy() b_start = self.img[:, :, 2].copy() #print r_start r_high = r_start.copy()#np.zeros_like(r_start) g_high = g_start.copy()#np.zeros_like(g_start) b_high = b_start.copy()#np.zeros_like(b_start) #color_pairs = permutations( # [r_start, g_start, b_start], 2) #print list(color_pairs) #color_pairs = [ # (r_high, g_start), (r_high, b_start), # (g_high, r_start), (g_high, b_start), # (b_high, r_start), (b_high, g_start)] #, 1), (red, 2), # (green, 0), (green, 2), # (blue, 0), (blue, 1)]: #def keep_if_greater(a, b): # a = np.where(a > b, a, 0) # return a #for a, b in color_pairs: # [(red, 1), (red, 2), # (green, 0), (green, 2), # (blue, 0), (blue, 1)]: # a = keep_if_greater(a, b)#self.img[:, :, b]) # print np.average(a), np.max(a) r_high = np.where(r_high > g_start, r_high, 0) r_high = np.where(r_high > b_start, r_high, 0) g_high = np.where(g_high > r_start, g_high, 0) g_high = np.where(g_high > b_start, g_high, 0) b_high = np.where(b_high > r_start, b_high, 0) b_high = np.where(b_high > g_start, b_high, 0) r_fin = np.where( r_high != 0, r_start + n, r_start - n) g_fin = np.where( g_high != 0, g_start + n, g_start - n) b_fin = np.where( b_high != 0, b_start + n, b_start - n) self.img = np.dstack((r_fin, g_fin, b_fin)) self.img = np.where(self.img >= 0, self.img, 0) self.img = np.where(self.img <= 255, self.img, 255) #img_fin = np.dstack((r_high, g_high, b_high)) #img_fin += n #((255 - img_fin) / n) #img_fin = np.where(img_fin <=255, img_fin, 255) #self.img -= n #self.img = np.where(img_fin >= self.img, # img_fin, self.img - n) if __name__ == '__main__': for image in images(): img = ColorHighlights(file_in=image) for n in [0, 1, 3, 5, 10, 20, 30, 50, 100, 255]: #, 3, 5, 10]: img.reload() img.highlight(n) img.save()