X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/canny.git/blobdiff_plain/9f314dc5ac38cf7f34832ddef1e3501c2b2820c4..16874923aed7a3bc8380a6041e5c6b3d82f5683c:/stc/exp/raphus/sobel555_for_ensemble.py diff --git a/stc/exp/raphus/sobel555_for_ensemble.py b/stc/exp/raphus/sobel555_for_ensemble.py index 37333f8..4a31c20 100644 --- a/stc/exp/raphus/sobel555_for_ensemble.py +++ b/stc/exp/raphus/sobel555_for_ensemble.py @@ -429,8 +429,8 @@ def compute_filter_canny(level,image,MsgLen): processed= array(processed.getdata()).flatten() List7=set(compute_list_bit_to_change(100,processed)) - #nb_bit_embedded=(512*512/10)+40 - nb_bit_embedded=max(2*MsgLen,int(len(List3)/MsgLen)*MsgLen)+40 + + nb_bit_embedded=max(2*MsgLen,int(len(List3)/MsgLen)*MsgLen) print "nb_bit_embedded",nb_bit_embedded AvailablePixel3=List3 AvailablePixel5=AvailablePixel3.union(List5) @@ -489,10 +489,115 @@ def compute_filter_canny(level,image,MsgLen): +def verifie(fileout,leng_msg,Message,): + global M,X + bit_to_read = 1 + dd2 = im.open(fileout) + dd2 = dd2.convert('RGB') + red2, green, blue = dd2.split() + level2=red2.copy() + + [List_bit_to_change2,Weight2]=compute_filter_canny(level2,dd2,leng_msg) + + + level2= array(level2.getdata()).flatten() + + print "support2",len(List_bit_to_change2) + print "message2",len(Message) + print "weight2",len(Weight2) + + alpha = float(len(List_bit_to_change2))/len(Message) + assert alpha >= 2 + index = min(int(alpha),9) + H_hat2 = { + 2 : [71,109], + 3 : [95, 101, 121], + 4 : [81, 95, 107, 121], + 5 : [75, 95, 97, 105, 117], + 6 : [73, 83, 95, 103, 109, 123], + 7 : [69, 77, 93, 107, 111, 115, 121], + 8 : [69, 79, 81, 89, 93, 99, 107, 119], + 9 : [69, 79, 81, 89, 93, 99, 107, 119, 125] + }[index] + + + print H_hat2 + + Stc_message2=[getBit(level2[l],bit_to_read) for l in List_bit_to_change2] + LL2=list(List_bit_to_change2) + """ + print "Level",max([level2[l]-level[l] for l in xrange(len(Stc_message2))]) + print "List bit to change",max([LL2[l]-LL1[l] for l in xrange(len(Stc_message))]) + print "Stc message", max([Stc_message[l]-Stc_message2[l] for l in xrange(len(Stc_message))]) + """ + Message2 = [x%2 for x in prod(H_hat2,len(Message),Stc_message2)] + level2=Message2 -def mystego(filein, fileout): +# print "mesg",Message +# print "mesg2",Message2 + + l=0 + val_mod2=0 + list_msg=[] + decoded_msg="" + + + + bbs = BlumBlumShub(); + bbs.setN(M) + bbs.setSeed(X) + + List_random=[] + while len(List_random)=leng_error*8 and val_mod2= 2 - index = min(int(alpha),9) - H_hat2 = { - 2 : [71,109], - 3 : [95, 101, 121], - 4 : [81, 95, 107, 121], - 5 : [75, 95, 97, 105, 117], - 6 : [73, 83, 95, 103, 109, 123], - 7 : [69, 77, 93, 107, 111, 115, 121], - 8 : [69, 79, 81, 89, 93, 99, 107, 119], - 9 : [69, 79, 81, 89, 93, 99, 107, 119, 125] - }[index] - - - print H_hat,H_hat2 - - Stc_message2=[getBit(level2[l],bit_to_read) for l in List_bit_to_change2] - LL1=list(List_bit_to_change); - LL2=list(List_bit_to_change2) - - print "Level",max([level2[l]-level[l] for l in xrange(len(Stc_message2))]) - print "List bit to change",max([LL2[l]-LL1[l] for l in xrange(len(Stc_message))]) - print "Stc message", max([Stc_message[l]-Stc_message2[l] for l in xrange(len(Stc_message))]) - Message2 = [x%2 for x in prod(H_hat2,len(Message),Stc_message2)] - level2=Message2 - -# print "mesg",Message -# print "mesg2",Message2 - print equiv(Message,Message2) - - print "fini" - - l=0 - val_mod2=0 - list_msg=[] - decoded_msg="" - - MessageDecoded2=[(int(Message2[l])^int(List_random[l])) for l in xrange(len(Message2))] -# print conv_list_bit(''.join([`MessageDecoded2[i]` for i in xrange(leng_error*8)])) -# print int(conv_list_bit(''.join([`MessageDecoded2[i]` for i in xrange(leng_error*8)]))) - - print conv_list_bit(''.join([`MessageDecoded2[i]` for i in xrange(len(Message2))])) - - - - - - -# for l in List_bit_to_change2: -# if(val_mod2=leng_error*8 and val_mod2