X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/canny.git/blobdiff_plain/3ee291cce4dfcc7d423c1060509f3f1c41a89b1c..a0f4d76521ca0d84f0de9ba71ecb094fc9e1af33:/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 3a1e5f5..4a31c20 100644 --- a/stc/exp/raphus/sobel555_for_ensemble.py +++ b/stc/exp/raphus/sobel555_for_ensemble.py @@ -12,11 +12,9 @@ from bbs import * infinity = 1000000000 - M=18532395500947174450709383384936679868383424444311405679463280782405796233163977*39688644836832882526173831577536117815818454437810437210221644553381995813014959 -# M clef X=18532395500947174450709383384936679868383424444311 -# X clef + @@ -431,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) @@ -479,63 +477,162 @@ def compute_filter_canny(level,image,MsgLen): Weight[l]=1000 l+=1 - - - List_bit_to_change=sub + return [sub,Weight] - return [sub,Weight] +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 + +# print "mesg",Message +# print "mesg2",Message2 + + l=0 + val_mod2=0 + list_msg=[] + decoded_msg="" -def mystego(filein, fileout): 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