0.0% ≤ diff ≤ 30.0%

7 clusters, 14 submissions

all: cluster #1 (2)

# 6330593221 (2021-04-04 18:47) %diff = 6.61 def embed_text_to_image(text, file_in, file_out): # print(file_in) list_of_img = load_image(file_in) copy_list_of_img = clone_image(list_of_img) num_point = len(copy_list_of_img)*len(copy_list_of_img[0])*3 #row x col x 3 run_num = 0 insert_bit = SPECIAL_BITS+int_to_bits(len(text))+''.join([char_to_bits(i) for i in text]) + SPECIAL_BITS # for i in text: # insert_bit += char_to_bits(i) # insert_bit += SPECIAL_BITS if num_point < 48+8*len(text): return False get_out_here = False for row in range(len(copy_list_of_img)): for col in range(len(copy_list_of_img[0])): for pixel in range(3): # print('run',run_num) # print(len(insert_bit)) if run_num >= len(insert_bit): get_out_here = True break if copy_list_of_img[row][col][pixel]%2 == 0: if insert_bit[run_num:run_num+1] == '1': copy_list_of_img[row][col][pixel] += 1 else: if insert_bit[run_num:run_num+1] == '0': copy_list_of_img[row][col][pixel] -= 1 run_num += 1 if get_out_here: break save_image(copy_list_of_img,file_out) # show_image(file_out) return True # print(list_of_img) # print(num_point) # -------------------------------------------------- def get_embedded_text_from_image(file_in): # print(file_in) list_of_img = load_image(file_in) copy_list_of_img = clone_image(list_of_img) run_test = 0 key_to_process = '' text = 2 for row in range(len(copy_list_of_img)): for col in range(len(copy_list_of_img[0])): for pixel in range(3): if key_to_process[:16] == SPECIAL_BITS[:run_test]: if len(key_to_process) == 32: text = bits_to_int(key_to_process[-16:]) if len(key_to_process) == 48+8*text: out = ''.join([bits_to_char(key_to_process[i + 32:i + 40]) for i in range(0, len(key_to_process[32:-16]), 8)]) if key_to_process[-16:] == SPECIAL_BITS: # show_image(file_in) return out else: key_to_process = '' run_test = 0 if copy_list_of_img[row][col][pixel]%2 == 0: key_to_process += '0' run_test += 1 else: key_to_process += '1' run_test += 1 return '' # --------------------------------------------------# 6330594921 (2021-04-05 22:02) %diff = 6.61 def embed_text_to_image(text, file_in, file_out): img = load_image(file_in) # ลิสต์ซ้อนสามชั้น img1 = clone_image(img) # [[[254, 255, 254], [196, 195, 191], [105, 101, 86],...]]] npoints = len(img1)*len(img1[0])*3 count = 0 bits = SPECIAL_BITS + int_to_bits(len(text)) + ''.join([char_to_bits(ch) for ch in text]) + SPECIAL_BITS if npoints < 48 + 8 * len(text): return False out = False for r in range(len(img1)): for c in range(len(img1[0])): for k in range(3): if count>=len(bits): out = True break if img1[r][c][k]%2 == 0: #ถ้าเป็นคู่ if bits[count:count+1] == '0': pass else: img1[r][c][k] += 1 else: #ถ้าเป็นคี่ if bits[count:count+1] == '1': pass else: img1[r][c][k] -= 1 count +=1 if out: break save_image(img1, file_out) return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): # แปลงรูปเป็นข้อความ img = load_image(file_in) img1 = clone_image(img) rt = 0; p = ''; txt = 2 for r in range(len(img1)): for c in range(len(img1[0])): for k in range(3): if p[:16] == SPECIAL_BITS[:rt]: if len(p) == 32: txt = bits_to_int(p[-16:]) if len(p) == 48 + 8 * txt: output = ''.join([bits_to_char(p[i + 32:i + 40]) for i in range(0, len(p[32:-16]), 8)]) if p[-16:] == SPECIAL_BITS: return output else: p = ''; rt = 0 if img1[r][c][k]%2 == 0: p += '0'; rt += 1 else: p += '1'; rt += 1 return '' # --------------------------------------------------

all: cluster #2 (2)

# 6330453021 (2021-04-05 23:24) %diff = 9.98 def embed_text_to_image(text, file_in, file_out): st_pic1 = load_image(file_in) st_pic2 = clone_image(st_pic1) code = [char_to_bits(i) for i in text ] Num = int_to_bits(len(code)) fillc = SPECIAL_BITS+Num+''.join(code)+SPECIAL_BITS efillc = [fillc[j] for j in range(0,len(fillc),3)] ch = 0 #------------------------------------------------------- for i in range(len(st_pic1)) : for j in range(len(st_pic1[0])) : for k in range(3) : if ch < len(code) : if st_pic1[i][j][k] %2 == 0 and fillc[ch] == '0' : st_pic2[i][j][k] = st_pic1[i][j][k] ; ch += 1 elif st_pic1[i][j][k] %2 == 0 and fillc[ch] == '1' : st_pic2[i][j][k] +=1 ; ch += 1 elif st_pic1[i][j][k] %2 != 0 and fillc[ch] == '0' : st_pic2[i][j][k] -= 1 ; ch += 1 elif st_pic1[i][j][k] %2 != 0 and fillc[ch] == '1' : st_pic2[i][j][k] = st_pic1[i][j][k] ; ch += 1 else : pass else : pass #------------------------------------------------------- if ch < len(fillc) : return False save_image(st_pic2, file_out) return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): pic = load_image(file_in) word = '' for e in pic: for k in e: for u in k : word += str(int(u)%2) if word.find(SPECIAL_BITS) == -1 : return '' x = word.find(SPECIAL_BITS) y = [word[j:j+16] for j in range(x,len(word),16)] z = chits_to_int(y[1]) y.remove(SPECIAL_BITS) y.remove(y[0]) word2 = "".join(y) x2 = word2.find(SPECIAL_BITS) y2,END = [word2[i:i+8] for i in range(0,x2,8) ] , [word2[e:e+16] for e in range(x2,len(word2),16)] if SPECIAL_BITS not in END or len(y2) != y: return '' last = ''.join([chits_to_char( e ) for e in y2 ]) return last # --------------------------------------------------# 6330455321 (2021-04-02 00:03) %diff = 9.98 def embed_text_to_image(text, file_in, file_out): img1 = load_image(file_in) img2 = clone_image(img1) code = [char_to_bits(e) for e in text] N = len(code) cN = int_to_bits(N) ecode = SPECIAL_BITS+cN+''.join(code)+SPECIAL_BITS ecode2 = [ecode[e] for e in range(0,len(ecode),3)] b = 0 for i in range(len(img1)) : for j in range(len(img1[0])) : for k in range(3) : if b < len(ecode) : if img1[i][j][k] %2 == 0 and ecode[b] == '0' : img2[i][j][k] = img1[i][j][k] ; b += 1 elif img1[i][j][k] %2 == 0 and ecode[b] == '1' : img2[i][j][k] +=1 ; b += 1 elif img1[i][j][k] %2 != 0 and ecode[b] == '0' : img2[i][j][k] -= 1 ; b += 1 elif img1[i][j][k] %2 != 0 and ecode[b] == '1' : img2[i][j][k] = img1[i][j][k] ; b += 1 else : pass else :pass # print(b) if b < len(ecode) : return False save_image(img2, file_out) # te = load_image(file_out) # if tcheck(te,img2) == False # return False return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): img = load_image(file_in) l = '' for i in img: for e in i: for E in e : l += str(int(E)%2) if l.find(SPECIAL_BITS) == -1 : return '' A = l.find(SPECIAL_BITS) D = [l[i:i+16] for i in range(A,len(l),16) ] N = bits_to_int(D[1]) D.remove(SPECIAL_BITS) D.remove(D[0]) l2 = "".join(D) A2 = l2.find(SPECIAL_BITS) D2 , END = [l2[i:i+8] for i in range(0,A2,8) ] , [l2[e:e+16] for e in range(A2,len(l2),16) ] if SPECIAL_BITS not in END or len(D2) != N: return '' fin = ''.join([bits_to_char( e ) for e in D2 ]) return fin # --------------------------------------------------

all: cluster #3 (2)

# 6330235621 (2021-04-05 19:02) %diff = 18.06 def embed_text_to_image(text, file_in, file_out): bit='' ex='0100111101001011' bit+=ex bit+=int_to_bits(len(text)) for e in text : bit+=char_to_bits(e) bit+=ex s=0 img=load_image(file_in) if len(bit)<=len(img)*len(img[0])*len(img[0][0]) : for r in range(len(img)) : if s<len(bit) : for c in range(len(img[r])) : if s<len(bit) : for i in range(len(img[r][c])) : if s<len(bit) : img[r][c][i]=insert(img[r][c][i],bit[s]) s+=1 else : break else : break else : break x=True else : x=False save_image(img,file_out) return x # -------------------------------------------------- def get_embedded_text_from_image(file_in): img=load_image(file_in) bit='' ex='0100111101001011' for r in range(len(img)) : for c in range(len(img[r])) : for i in range(len(img[r][c])) : bit+=reinsert(img[r][c][i]) if len(bit)>=48 : if bit[:16]==ex : N=bits_to_int(bit[16:32]) if bit[32+8*N:48+8*N]==ex : x=bit[32:32+8*N] else : x='' else : x='' else : x='' a=int(len(x)/8) b='' for e in range(a) : c=x[8*e:8*(e+1)] b+=bits_to_char(c) return b # -------------------------------------------------- def insert(C,b) : if C%2==0 : if b=='0' : x=C elif b=='1' : x=C+1 elif C%2==1 : if b=='0' : x=C-1 elif b=='1' : x=C return x def reinsert(x) : if x%2==0 : y='0' elif x%2==1 : y='1' return y # --------------------------------------------------# 6330350021 (2021-04-05 17:47) %diff = 18.06 def embed_text_to_image(text, file_in, file_out): bits = '' extra = '0100111101001011' bits += extra bits += int_to_bits(len(text)) for ch in text: bits += char_to_bits(ch) bits += extra n = 0 img = load_image(file_in) if len(img)*len(img[0])*len(img[0][0]) >= len(bits): for i in range(len(img)): if n < len(bits): for j in range(len(img[i])): if n < len(bits): for k in range(len(img[i][j])): if n < len(bits): img[i][j][k] = insert_bits(img[i][j][k],bits[n]) n += 1 else: break else: break else: break enough = True else: enough = False save_image(img,file_out) return enough # -------------------------------------------------- def get_embedded_text_from_image(file_in): img = load_image(file_in) bits = '' sentence = '' extra = '0100111101001011' for i in range(len(img)): for j in range(len(img[i])): for k in range(len(img[i][j])): bits += read_char(img[i][j][k]) if len(bits) >= 48: if bits[0:16:] == extra: n = bits_to_int(bits[16:32:]) if bits[32+8*n:48+8*n:] == extra: a = bits[32:32+8*n:] else: a = '' else: a = '' else: a = '' for i in range(int(len(a)/8)): z = a[8*i:8*i+8:] sentence += bits_to_char(z) return sentence # -------------------------------------------------- def insert_bits(original, insert): if original%2 == 0: if insert == '0': a = original else: a = original+1 else: if insert == '0': a = original-1 else: a = original return a def read_char(original): if original%2 == 0: a = '0' else: a = '1' return a # --------------------------------------------------

all: cluster #4 (2)

# 6330568621 (2021-04-04 20:40) %diff = 19.08 def embed_text_to_image(text, file_in, file_out): old_img = load_image(file_in) if 48+len(text)*8>bits_of_img(old_img): #Need a bigger picture return False else: new_img = clone_image(old_img) len_bits = int_to_bits(len(text)) text_bits = "" for letter in text: text_bits+=char_to_bits(letter) answer = SPECIAL_BITS+len_bits+text_bits+SPECIAL_BITS convert_img(new_img,answer) save_image(new_img,file_out) return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): img = load_image(file_in) ans = "" if get_N_bits(img,16)==SPECIAL_BITS: #found starting special bits (embedded code) len_word_bits=get_N_bits(img,32)[16:] len_word=bits_to_int(len_word_bits) if get_N_bits(img,48+8*len_word)[-16:]==SPECIAL_BITS: #found ending special bits for i in range(len_word): start=32+i*8 ans+=bits_to_char(get_N_bits(img,48+8*len_word)[start:start+8]) return ans # -------------------------------------------------- def bits_of_img(img): count=0 for a in img: for b in a: for c in b: count+=1 return count def convert_img(img,bits): count=0 for i in range(len(img)): for j in range(len(img[i])): for k in range(len(img[i][j])): if count>=len(bits): #dont edit more than needed return if img[i][j][k]%2==0 and bits[count]=='1': img[i][j][k]+=1 elif img[i][j][k]%2!=0 and bits[count]=='0': img[i][j][k]-=1 count+=1 # -------------------------------------------------- def get_N_bits(img,N): ans="" n=0 for a in img: for b in a: for c in b: if n>=N: return ans if c%2==0: ans+="0" else: ans+="1" n+=1 return ans# 6330577221 (2021-04-04 16:48) %diff = 19.08 def embed_text_to_image(text, file_in, file_out): img_in=load_image(file_in) if 8*len(text)+48>count_bit(img_in): return False img_out=clone_image(img_in) bit_len=int_to_bits(len(text)) bit_text='' for ch in text: bit_text+=char_to_bits(ch) bit=SPECIAL_BITS+bit_len+bit_text+SPECIAL_BITS embed_bit(img_out,bit) save_image(img_out,file_out) return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): img=load_image(file_in) word='' if check_bit(img,16)==SPECIAL_BITS: len_word_bits=check_bit(img,32)[16:] len_word=bits_to_int(len_word_bits) if check_bit(img,48+len_word*8)[32+len_word*8:]==SPECIAL_BITS: for i in range(len_word): word_bits=check_bit(img,32+(i+1)*8)[32+i*8:] word+=bits_to_char(word_bits) return word # -------------------------------------------------- def count_bit(img): n=0 for i in img: for j in i: for k in j: n+=1 return n def embed_bit(img,bit): i=0 for e in range(len(img)): for j in range(len(img[e])): for c in range(len(img[e][j])): if i>=len(bit): return img if img[e][j][c]%2==0: if bit[i]=='1': img[e][j][c]+=1 else: if bit[i]=='0': img[e][j][c]-=1 i+=1 return img # -------------------------------------------------- def check_bit(img, N): bit='' n=0 for i in img: for j in i: for k in j: if n>=N: return bit if k%2==0: bit+='0' n+=1 else: bit+='1' n+=1 return bit

all: cluster #5 (2)

# 6330199721 (2021-04-05 22:11) %diff = 22.99 def embed_text_to_image(text, file_in, file_out): a = '' b = 0 img = clone_image(load_image(file_in)) no = int_to_bits(len(text)) for e in text: a += char_to_bits(e) z = SPECIAL_BITS+no+a+SPECIAL_BITS if 3*len(img)*len(img[0]) < len(z): return False else: for row in range(len(img)): for col in range(len(img[row])): for i in range(3): if img[row][col][i]%2 == 0: if z[b] == '0': b += 1 else: img[row][col][i] += 1 b += 1 elif z[b] == '0': img[row][col][i] -= 1 b += 1 else: b += 1 if b == len(z): break if b == len(z): break save_image(img, file_out) return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): a = '' b = '' c = '' img = clone_image(load_image(file_in)) for row in img: for col in row: for i in col: if int(i)%2 == 0: b += '0' else: b += '1' if b[:16] == SPECIAL_BITS: z = bits_to_int(b[16:32]) if b[32+z*8:48+z*8] == SPECIAL_BITS: c += b[32:32+z*8] for i in range(len(c)//8): a += bits_to_char(c[8*i:8*i+8]) return a # --------------------------------------------------# 6330205821 (2021-04-04 18:30) %diff = 22.99 def embed_text_to_image(text, file_in, file_out): txt = '' ans = '' im = load_image(file_in) img = clone_image(im) no = int_to_bits(len(text)) for e in text: txt += char_to_bits(e) tt = SPECIAL_BITS+no+txt+SPECIAL_BITS if 3*len(img)*len(img[0]) < len(tt): return False else: k =0 for row in range(len(img)): for co in range(len(img[row])): for c in range(3): if img[row][co][c]%2 == 0: if tt[k] == '0': k+=1 elif tt[k] =='1': img[row][co][c] += 1 k+=1 else: if tt[k] == '0': img[row][co][c] -= 1 k+=1 elif tt[k] =='1': k+=1 if k == len(tt): break if k == len(tt): break if k == len(tt): break save_image(img, file_out) return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): ans = '' bit = '' imbit = '' im = load_image(file_in) img = clone_image(im) for row in img: for co in row: for i in co: if int(i)%2 == 0: bit += '0' else: bit += '1' if bit[:16] != SPECIAL_BITS: return '' else: no = bits_to_int(bit[16:32]) if bit[32+no*8:48+no*8] != SPECIAL_BITS: return '' else: imbit += bit[32:32+no*8] for x in range(len(imbit)//8): ans += bits_to_char(imbit[8*x:8*x+8]) return ans # --------------------------------------------------

all: cluster #6 (2)

# 6330234021 (2021-04-05 16:17) %diff = 25.82 def embed_text_to_image(text, file_in, file_out): x = load_image(file_in) clone_x = clone_image(x) textbit = SPECIAL_BITS textbit += int_to_bits(len(text)) c = len(clone_x)*len(clone_x[0])*len(clone_x[0][0]) h = 0 h1 = False for i in text: textbit += char_to_bits(i) textbit += SPECIAL_BITS if c < len(textbit): return False else: for p in range(len(clone_x)): for l in range(len(clone_x[0])): for k in range(3): h += 1 if textbit[(l*3)+k+(p*len(clone_x[0])*3)] == "0": if clone_x[p][l][k]%2 == 0: clone_x[p][l][k] = clone_x[p][l][k] else: clone_x[p][l][k] = (int(clone_x[p][l][k]) - 1) elif textbit[(l*3)+k+(p*len(clone_x[0])*3)] == "1": if clone_x[p][l][k]%2 == 0: clone_x[p][l][k] = (int(clone_x[p][l][k]) + 1) else: clone_x[p][l][k] = clone_x[p][l][k] if h == len(textbit): h1 = True break if h1:break if h1:break save_image(clone_x, file_out) return True # -------------------------------------------------- def get_embedded_text_from_image(file_in): file_in = load_image(file_in) bit = '' for i in file_in : for j in i : for k in j : if k%2 == 0 : bit += '0' elif k%2 == 1 : bit += '1' for i in range(len(bit)) : if bit[i:i+16] == SPECIAL_BITS : n = bits_to_int(bit[i+16:i+32]) bit1 = bit[i+32:i+32+(8*n)] bit1_1 = '' if bit[i+32+(8*n):i+32+16+(8*n)] == SPECIAL_BITS : for j in range(0,len(bit1),8): bit1_1 += bits_to_char(bit1[j:j+8]) return bit1_1 else : bit = '' return bit # --------------------------------------------------# 6330236221 (2021-04-03 22:54) %diff = 25.82 def embed_text_to_image(text, file_in, file_out): a = load_image(file_in) clone_a = clone_image(a) textbit = SPECIAL_BITS textbit += int_to_bits(len(text)) c = len(clone_a)*len(clone_a[0])*len(clone_a[0][0]) h = 0 h1 = False for i in text: textbit += char_to_bits(i) textbit += SPECIAL_BITS if c < len(textbit): return False else: for p in range(len(clone_a)): for l in range(len(clone_a[0])): for k in range(3): h += 1 if textbit[(l*3)+k+(p*len(clone_a[0])*3)] == "0": if clone_a[p][l][k]%2 == 0: clone_a[p][l][k] = clone_a[p][l][k] else: clone_a[p][l][k] = (int(clone_a[p][l][k]) - 1) elif textbit[(l*3)+k+(p*len(clone_a[0])*3)] == "1": if clone_a[p][l][k]%2 == 0: clone_a[p][l][k] = (int(clone_a[p][l][k]) + 1) else: clone_a[p][l][k] = clone_a[p][l][k] if h == len(textbit): h1 = True break if h1:break if h1:break save_image(clone_a, file_out) return True def get_embedded_text_from_image(file_in): a = load_image(file_in) s = [] c = "" p = 0 c1 = 0 g1 = [] g = [] text = "" for i in a: for k in i: for iny in k: s.append(iny) for i in s: if i%2 == 0: c += "0" else: c += "1" if c[:16] == '0100111101001011': p = c[16:32] p = bits_to_int( c[16:32]) for i in c[32:32 + p*8]: c1 += 1 g.append(i) if c1 == 8: g1.append("".join(g)) g = [] c1 = 0 for i in g1: text += bits_to_char( i ) if c[32 + p*8:48 + p*8] == '0100111101001011': return text else: return '' else: return '' # --------------------------------------------------

all: cluster #7 (2)

# 6330180721 (2021-04-05 22:49) %diff = 29.39 def embed_text_to_image(text, file_in, file_out): if len(text)>65535: return False img = load_image(file_in) img1 = clone_image(img) if 16 + 8*len(text)/3 > len(img)*len(img[0]): return False bit = SPECIAL_BITS + int_to_bits(len(text)) for e in text: bit += char_to_bits(e) bit += SPECIAL_BITS h = len(img[0])*3 for e in range(len(bit)): if img[e//h][(e%h)//3][e%3] % 2 == 0 and bit[e] == '1': img[e//h][(e%h)//3][e%3] = img[e//h][(e%h)//3][e%3] + 1 elif img[e//h][(e%h)//3][e%3] % 2 == 1 and bit[e] == '0': img[e//h][(e%h)//3][e%3] = img[e//h][(e%h)//3][e%3] - 1 save_image(img,file_out) if text == get_embedded_text_from_image(file_out): return True return False # -------------------------------------------------- def get_embedded_text_from_image(file_in): img = load_image(file_in) specialbit = check(0,16,img) if specialbit != SPECIAL_BITS: return '' lenbit = check(16,32,img) bitlen = bits_to_int(lenbit) textbit = check(32,32+8*bitlen,img) bittext = '' for e in range(0,len(textbit),8): bittext += bits_to_char(textbit[e:e+8]) speciallast = check(32+8*bitlen,48+8*bitlen,img) if speciallast != SPECIAL_BITS: return '' return bittext # -------------------------------------------------- def check(a,b,img1): text = '' h = len(img1[0])*3 for i in range(a,b): if img1[i//h][(i%h)//3][i%3] %2 == 0: text += '0' else: text += '1' return text # --------------------------------------------------# 6330572021 (2021-04-05 11:18) %diff = 29.39 def embed_text_to_image(text, file_in, file_out): img_file=load_image(file_in) new_img=clone_image(img_file) l=len(text) if len(img_file)*len(img_file[0])<16+(8*l)/3: return False new_bit=SPECIAL_BITS+int_to_bits(l) for c in text: new_bit+=char_to_bits(c) new_bit+=SPECIAL_BITS r=len(img_file)*3 for i in range(len(new_bit)): if img_file[i//r][(i%r)//3][(i%r)%3]%2==0: if new_bit[i]=='1': new_img[i//r][(i%r)//3][(i%r)%3]=img_file[i//r][(i%r)//3][(i%r)%3]+1 elif img_file[i//r][(i%r)//3][(i%r)%3]%2!=0: if new_bit[i]=='0': new_img[i//r][(i%r)//3][(i%r)%3]=img_file[i//r][(i%r)//3][(i%r)%3]-1 save_image(new_img,file_out) if text==get_embedded_text_from_image(file_out): return True return False # -------------------------------------------------- def get_embedded_text_from_image(file_in): img_file=load_image(file_in) text='' startcode=c_to_b(img_file,0,16) if startcode!=SPECIAL_BITS: return text n=c_to_b(img_file,16,32) len_bit=bits_to_int(n) code=c_to_b(img_file,32,32+len_bit*8) for i in range(0,len(code),8): text+=bits_to_char(code[i:i+8]) endcode=c_to_b(img_file,32+len_bit*8,48+len_bit*8) if endcode!=SPECIAL_BITS: return'' return text # -------------------------------------------------- def c_to_b(img,a,b): r=len(img[0])*3 s='' for i in range(a,b): if img[i//r][(i%r)//3][(i%r)%3]%2==0: s+='0' else: s+='1' return s # --------------------------------------------------