matlab怎么批量读取一个文件夹中命名规律的tif文件?

matlab怎么批量读取一个文件夹中命名规律的tif文件?,第1张

其实这种网上可以找到很多的……

clc;clear;

%工作目录是图形所在目录

Files=dir(['tif']);  

number=length(Files); 

sum_rbg_img = 0;

sum_gray_img = 0;

for i=1:number  

rbg_img=imread([Files(i)name]);  

sum_rbg_img = sum_rbg_img + rbg_img;  %% RGB 值

gray_img = rgb2gray(rbg_img);

sum_gray_img  = sum_gray_img + gray_img;  %% 灰度值

end 

% 平均值

av_rbg_img = sum_rbg_img/number;

av_gray_img = sum_gray_img/number;

方法一:arcgis

获取栅格属性工具和栅格计算器一样,经常失灵(例如,尽管选了计算第二个波段的均值,但是结果还是第一个波段的均值),老是得到一些错误的结果,有可能是因为破解版的原因,我没用过正版的,所以没办法测试是不是破解版的才会出错。还有一个小tip,在使用这个工具之前,最好先用计算统计数据计算后再用获取栅格属性。

方法二

这个方法其实我也没用过,只是在csdn有看到。有一种是通过gdal遍历所有像元及其像素值,然后再计算平均值和方差,麻烦的我直接放弃。后来又看到了类似arcpyGetRasterProperties_management()函数,就是

dsoutGetRasterBand(i)ComputeStatistics()。

可以LSB隐写分析

任意比例的LSB嵌入率分析

LSB隐写分析

基于视觉攻击的LSB隐写分析

分解灰度图

抽取最低位平面

任意比例嵌入率的分析

基于卡方检验的LSB隐写分析

原始图像与载密图像的灰度直方图对比

卡方检测分析

任意比例嵌入率的卡方检测分析

基于视觉攻击的LSB隐写分析

视觉攻击是指利用人的视觉感知特性来判断载密图像异常变化。LSB替换选用最低位平面来嵌入秘密信息,最低位平面对图像的视觉效果影响最轻微。因此,可以从图像的最低有效位组成的图像中判断是否有隐藏消息。图像的LSB和最高位以及其他点有一定的关系,特别是对自然拍摄的BMP图像。但是在选择嵌入位置时,一般都同等对待载体中所有样本点,忽略了载体本身存在的空间相关性,就能够被观察出嵌入的痕迹。

分解灰度图

对图像进行位平面分解:位平面是指依次取出每个像素点对应位的值组成一个位平面。一副灰度图像中每个像素点的灰度值可以由8个二进制来表示,因此可以分解成8个位平面。举例,假设图像有两个像素点,灰度值分别为1和3,其对应的二进制为分别为00000001和00000011,那么该图像分解成的8个位平面以此为00、00、00、00、00、00、01、11。每个位平面均为一个二值图,即像素点的值非0即1。

bitplanek = bitget(A,k); %获取A的第k位

clc

clear

A = imread("lennahidebmp");

figure(1);

subplot(3,3,1);

imshow(A);

title('原始图像');

[h,w] = size(A);

for k=1:8

tmp = bitget(A,k);

subplot(3,3,k+1);

imshow(tmp,[]);

B = num2str(k+1);

title('位平面%s',B);

end;

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

在这里插入描述

抽取最低位平面

分别抽取载密图像和原图像的最低位平面,进行对比

lsbbitplanek = bitget(A,1); %获取A的第1位

clc

clear

A = imread('lena_256tiff');

[h,w] = size(A);

figure();

tmp = bitget(A,1);

subplot(1,2,1);

imshow(tmp,[]);

title('原始图像的最低位平面');

B = imread('lsbwatermarkedlenatiff');

[h,w] = size(B);

tmp1 = bitget(B,1);

subplot(1,2,2);

imshow(tmp1,[]);

title('载密图像的最低位平面');

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

在这里插入描述

任意比例嵌入率的分析

在不同嵌入率10%、30%、50%、70%下进行分析对比

function [ S,P_value ] = lsbplanekunit( image,rate )

% 函数功能:先对图像以嵌入率为rate进行顺序LSB嵌入,然后进行视觉隐写分析

% 输入参数:input是原始图像,rate是嵌入率,取值在[0,1]

% 调用例子:[ S,P_value ] = lsbplanekunit( 'livingroomtif',05 )

%读一幅图像

cover=imread(image);

%cover=cover(:,:,1);

ste_cover=double(cover);

[m,n]=size(ste_cover);

%依据rate计算秘密信息位的长度,并生成秘密信息msg

msglen=floor(mnrate);

msg= rand(1,msglen); %这里可以直接用randint,如果机器上有的话

for i=1:msglen

if msg(i)>=05

msg(i)=1;

else

msg(i)=0;

end

end

%使用lsb隐写算法嵌入秘密信息

p=1;

for f2=1:n

for f1=1:m

if p>=msglen

break;

end

ste_cover(f1,f2)=ste_cover(f1,f2)-mod(ste_cover(f1,f2),2)+msg(1,p);

p=p+1;

end

if p==msglen

break;

end

end

A = imread(image);

[h,w] = size(A);

figure();

tmp = bitget(A,1);

subplot(1,2,1);

imshow(tmp,[]);

title('原始图像的最低位平面');

B = ste_cover;

[h,w] = size(B);

tmp1 = bitget(B,1);

subplot(1,2,2);

imshow(tmp1,[]);

title('载密图像的最低位平面');

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

在这里插入描述

基于卡方检验的LSB隐写分析

chi-square分析又称卡方分析。普通图像像素值的分布情况由于LSB嵌入会发生变化。使用LSB嵌入水印时,如果像素值最低位比特与水印比特相同,那么保留该像素值不做变化;否则,使用水印比特位代替像素值的最低比特位。例如,水印比特位为1时,若像素值为(128)D=(1000 0000)B,则将像素值变为(129)D=(1000 0001)B;若像素值为(17)D=(0001 0001)B,则不改变该像素值。

分析该处理过程,像素值会由2i变为2i+1,而不会变为2i-1;或者由2i+1变为2i,而不会变为2i+2。即像素值在值对2i和2i+1之间翻转。因此,若用hi表示像素值为i的像素个数,那么,使用LSB嵌入后,h2i和h2i+1会比较接近,远小于普通图像中h2i和h2i+1的距离。

在这里插入描述

该值在嵌入前后不发生变化,当较大时,根据中心极限定理,下式成立。

在这里插入描述

在这里插入描述 服从标准正态分布。因此,统计量 服从自由度为k的开方分布。k为h2i和h2i+1组成的数字对,为0时不记在内。

在这里插入描述

由于在这里插入描述 越小,表明h2i和h2i+1越接近,因此也意味着图像含水印的概率也越高。可以利用卡方分布的概率密度函数计算载体被隐写的概率:

在这里插入描述

卡方分析不仅能够对隐写率做出分析,能且能够判断嵌入位置。但如果隐写率较低,或者嵌入位置随机分布,卡方分析就难以奏效。

原始图像与载密图像的灰度直方图对比

对原始图像和载密图像进行灰度直方图对比,选取部分像素值,观察h2i和h2i+1的在嵌入前和嵌入后的差值情况

n = hist(A(:), 0:255)’; %获取A的像素值分布,n为像素值统计矩阵,索引为像素值,值为该像素值的个数

stem(a:b,n(a+1:b+1)); %画出直方图,a:b为像素值区间

figure(3);

I1 = imread('lena_256tiff');

A = I1(:,:,1);

subplot(1,2,1);

[m,n]=size(A);

[counts,x] = imhist(A,32);

counts = counts/(mn);

stem(x,counts);

I2 = imread('lsbwatermarkedlenatiff');

B = I2(:,:,1);

subplot(1,2,2);

[a,b]=size(B);

[counts,y] = imhist(B,32);

counts = counts/(ab);

stem(y,counts);

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

在这里插入描述

卡方检测分析

依次取图像的部分比例区域,逐渐扩大,如从10%开始,每次加1%,直到100%

对这部分区域进行卡方检测,编写卡方检测函数

统计h2i和h2i+1 ,计算

计算在这里插入描述

计算自由度k下的密度函数,得到隐写概率

p = 1 - chi2cdf(r, k - 1) %p为隐写概率,chi2cdf(r, k - 1)为卡方分布的概率密度函数

绘制分析区域比例和隐写概率曲线图

plot(x, p(1, :), ‘k-’, x, p(2, :), ‘r-’, x, p(3, :), ‘b–’, x, p(4, :), ‘g–’, x, p(5, :), ‘c–’, x, p(8, :), ‘y–’); %绘制曲线函数,x为区域比例,p为不同嵌入率下的隐写概率

axis([10 100 0 12]); %坐标轴

legend(‘0%’, ‘10%’, ‘20%’, ‘30%’, ‘40%’, ‘70%’); %图例

xlabel(‘Size of sample(%)’); %横坐标轴说明

ylabel(‘Probability of embedding’); %纵坐标轴说明

clc

clear

I = imread('lena512bmp');

sz = size(I);

for k = 1:11

rt = double(k-1)/10;

row = round(sz(1)rt);

fprintf(1,'rt:%d\n',row);

col = sz(2);

msg = randsrc(row,col,[0 1;05 05]);

stg =I;

stg(1:row,1:col) = bitset(stg(1:row,1:col),1,msg);

imwrite(stg,sprintf('stg_%dbmp',floor(100rt)));

i =1;

for rto = 01:001:1

row = round(sz(1)rto);

col = round(sz(2)rto);

p(k,i) = LsbPrb(stg(1:row,1:col));

i=i+1;

end;

end;

x = round([01:001:1]sz(1))/sz(1)100;

figure;

plot(x,p(1,:),'k-',x,p(2,:),'r-',x,p(3,:),'b--',x,p(4,:),'g--',x,p(5,:),'c--',x,p(8,:),'y--');

axis([10 100 0 12]);

legend('0%','10%','20%','30%','40%','70%');

xlabel('Size of sample(%)');

ylabel('Probability of embedding');

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

其中的LsbPrbm代码如下

function p=LsbPrb(x)

n=sum(hist(x,[0:255]),2);

h2i=n([3:2:255]);

h2is=(h2i+n([4:2:256]))/2;

filter=(h2is~=0);

k=sum(filter);

idx=zeros(1,k);

for i=1:127

if filter(i)==1

idx(sum(filter(1:i)))=i;

end;

end;

r=sum(((h2i(idx)-h2is(idx)) ^2)/(h2is(idx)));

p=1-chi2cdf(r,k-1);

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1

2

3

4

5

6

7

8

9

10

11

12

13

14

在这里插入描述

任意比例嵌入率的卡方检测分析

在不同嵌入率0%、10%、30%、50%、70%下进行检测,分析检测的结果

function [ S,P_value ] = kafangunit( image,rate )

% 函数功能:先对图像以嵌入率为rate进行顺序LSB嵌入,然后进行卡方隐写分析

% 输入参数:input是原始图像,rate是嵌入率,取值在[0,1]

% 输出参数:S存放卡方统计值,P保存对应的p值,即观察值与估计值相似程度的概率

% 调用例子:[ S,P_value ] = kafang( 'livingroomtif',05 )

%读一幅图像

cover=imread(image);

%cover=cover(:,:,1);

ste_cover=double(cover);

[m,n]=size(ste_cover);

%依据rate计算秘密信息位的长度,并生成秘密信息msg

msglen=floor(mnrate);

msg= rand(1,msglen); %这里可以直接用randint,如果机器上有的话

for i=1:msglen

if msg(i)>=05

msg(i)=1;

else

msg(i)=0;

end

end

%使用lsb隐写算法嵌入秘密信息

p=1;

for f2=1:n

for f1=1:m

if p>=msglen

break;

end

ste_cover(f1,f2)=ste_cover(f1,f2)-mod(ste_cover(f1,f2),2)+msg(1,p);

p=p+1;

end

if p==msglen

break;

end

end

I = ste_cover

sz = size(I);

for k = 1:11

rt = double(k-1)/10;

row = round(sz(1)rt);

fprintf(1,'rt:%d\n',row);

col = sz(2);

msg = randsrc(row,col,[0 1;05 05]);

stg =I;

stg(1:row,1:col) = bitset(stg(1:row,1:col),1,msg);

imwrite(stg,sprintf('stg_%dbmp',floor(100rt)));

i =1;

for rto = 01:001:1

row = round(sz(1)rto);

col = round(sz(2)rto);

p(k,i) = LsbPrb(stg(1:row,1:col));

i=i+1;

end;

end;

x = round([01:001:1]sz(1))/sz(1)100;

figure;

plot(x,p(1,:),'k-',x,p(2,:),'r-',x,p(3,:),'b--',x,p(4,:),'g--',x,p(5,:),'c--',x,p(8,:),'y--');

axis([10 100 0 12]);

legend('0%','10%','20%','30%','40%','70%');

xlabel('Size of sample(%)');

ylabel('Probability of embedding');

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

在这里插入描述

参考文章

https://blogcsdnnet/HizT_1999/article/details/106951364utm_medium=distributepc_relevantnone-task-blog-baidujs_baidulandingword-0&spm=1001210130014242

参考代码

https://githubcom/kalpatian/information_hidding

TIFCTY:tonight, I feel close to you

是仓木麻衣和孙燕姿的歌

歌词:

close my eyes and feel your mind

time has passed

i walk like a shadow

never knew

what i am going through

you touch my heart and take my breath away

whisper on the wind so softly

let the bright stars fill out dreams with love

reach for your hand (you're holding my key)

and you show me the way

tonight, i feel close to you

you open my door and light the sky above

when i need a friend, you are there right by my side

i wish we could stay as one

i wish we could stay forever as one

all the tears that haunt my past

you promised

it'll be better tomorrow

play that song

you and i listened to

and let it gently ease our pain

tender rain drops from the blue sky

flowers blooming, life is so divine

like sunlight on a stream (you'reholding my key)

you show the world to me

tonight, i feel close to you

you open my door and light the sky above

when i need a freand, you are there right by my side

i wish we could stay as one

so much love in this beautiful world

search for the brightest star in the sky

you will find the meaning of love

don't be afraid (don't be afraid), just be yourself (just be yourself)

we need this love i've never knew

下载地址:

http://wwwchinazrjcom/blog/upload/Tonight,I%20Feel%20Close%20To%20Yoump3

或者你把歌名输入百度歌曲搜索就能找到!

(那女孩有暗示噢~~嘿嘿~~)

意思是:

1、贝蒂是我最好的朋友之一。她身材纤细并且留着短发。贝蒂是大方的。她乐于和朋友们分享她的东西。她也乐于助人,随时准备帮助别人,她在我的家庭作业上给予帮助,她总是在公共汽车上给需要的人让座。贝蒂有一副好嗓子,她长大后想当一名歌手。

2、我最好的朋友是马克斯,他是我们家个子最高的男孩。几乎175米。他戴着一副小圆眼镜。他们使他看起来很聪明。马克斯很有幽默感。他讲幽默的笑话并且总是逗我笑。我和他在一起从那个没感觉到无聊。马克思的腿非常长。

它们不太适合放在他桌子下面。当他走过我们的课桌时,他经常把我们的书和笔打翻在地板上。马克斯是一个有趣的人。

3、梅是我最好的朋友。她比我矮。他有一双明亮的眼睛,直直的长发。每个人都认为她很漂亮。梅是亲切的。她经常微笑,从不说任何人的坏话。

梅是一个诚实的朋友。当我烦恼的时候,我可以随时去找她。我能告诉他任何事情,因为她能保守秘密。

原文:

1、 Betty is one of my best friends She is slim and has short hairBetty is generous She is willing to share things with her friends She is also helpful ready to help people anytime She helps me with my homework and she always gives her seat on the bus to someone in need

Betty has a good voic She wants to bea singer when she grows up

2、My best friend is MaxHe is the tallest boy in our dass--almost 175 metres He wears small round glasses Thay make him look swart Max has a road sose of humour He tells funny jokes and always makes me laugh I mever feel bored with him

Man's legs are very long They do not well under his deskWhen he waliks past our desks,he often knocks our books and pens onto the floor Max is so interesting!

3、 May is my best friend she is shorter than I am She has big bright eyes and long straight hair Everyone thinks she is pretty May is sweet she smiles often and never says a bad word about anyone

May is a true friend When something worries me, I can always go to her I can tell her anything because she can keep a secret

public static void many2one(List<String> bookFilePaths, String toPath,String distFileName) {

    if (bookFilePaths != null && bookFilePathssize() > 0) {

     File[] files = new File[bookFilePathssize()];

     for(int i = 0; i < bookFilePathssize(); i++){

      files[i] =  new File(bookFilePathsget(i));

     }

     if (files != null && fileslength > 0) {

      

      try {

       ArrayList pages = new ArrayList(fileslength - 1);

       FileSeekableStream[] stream = new FileSeekableStream[fileslength];

       for (int i = 0; i < fileslength; i++) {

        stream[i] = new FileSeekableStream(

          files[i]getCanonicalPath());

       }

       ParameterBlock pb = (new ParameterBlock());

       PlanarImage firstPage = JAIcreate("stream", stream[0]);

       for (int i = 1; i < fileslength; i++) {

        PlanarImage page = JAIcreate("stream", stream[i]);

        pagesadd(page);

  

       }

       TIFFEncodeParam param = new TIFFEncodeParam();

       File f = new File(toPath);

       if(!fexists()){

        fmkdirs();

       }

       OutputStream os = new FileOutputStream(toPath + Fileseparator+ distFileName);

       ImageEncoder enc = ImageCodeccreateImageEncoder("tiff",

         os, param);

       paramsetExtraImages(pagesiterator());

       encencode(firstPage);

       for (int i = 0; i < fileslength; i++) {

        stream[i]close();

           if(files[i]isFile()&&files[i]exists()){

         files[i]delete();

        }

       }

       osclose();

      } catch (IOException e) {

       eprintStackTrace();

      }

     }

    }

   }

欢迎分享,转载请注明来源:品搜搜测评网

原文地址:https://pinsoso.cn/meirong/1933694.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-10-28
下一篇2023-10-28

随机推荐

  • 妮维雅粉水

    分类:生活 >> 美容塑身问题描述:看到很多网上评论说妮维雅粉水很赞 我的皮肤有点小干 应该适合 上面说有收缩毛孔的作用 可我皮肤挺细的 日常护肤一定要用爽肤水吗? 解析:我是油皮,使用了3瓶了,觉得一

    2024-04-15
    21700
  • 一瓶神仙水230ml成本

    -ll神仙水230ml :1520元一瓶精华水80MI:560元眼霜15MI:640元一套加起来在2720左右,敬请参考:Sk2明星产品:1、SK-II环采臻皙钻白精华露这款精华人称它为"小灯泡"。提取自日本杏的珍稀精萃及Pixel-Whi

    2024-04-15
    19900
  • 精华露和精华液的区别

    精华露和精华液的区别在于质地不同、使用方法不同、适合人群不同。1、质地不同精华露是高浓缩后的护肤品,例如著名品牌SK神仙水就是这类型的产品,质地较为粘稠,更适合干性皮肤使用。但对于油性肌肤,因为油脂分泌旺盛的缘故,不太适合多种精华类的护肤品

    2024-04-15
    14800
  • 凝露,乳液,保湿露,面霜,精华素有什么区别?

    凝露,乳液,保湿露,面霜,精华素有什么区别以植物医生为例。从适用人群来解释:乳液适合混合型皮肤的人用,春秋干燥的季节用来补水效果不错。而凝露多是无油配方,喜欢出油的MM们使用效果会很好。所以爱出油的妹子们选择凝露来调节肌肤的水油平衡,是最好

    2024-04-15
    9200
  • 润唇膏哪个牌子好

    润唇膏哪个牌子好要说什么护肤品走哪带哪,一定非润唇膏莫属了,随身必定携带一支,公司和家里也分别都留有存货。那么你们知道润唇膏哪个牌子好吗?有关唇膏的使用,个人有时一天涂十几次,最通常的情况是早上唇膏打底,晚上唇膏滋养,一年四季不间断,秋冬使

    2024-04-15
    10900
  • 美白身体乳排名第一名

    美白身体乳排名第一是妮维雅身体乳。妮维雅是一家德国大型性护肤品和身体护理品品牌,也是一家致力于护肤品研发和销售的跨国企业,成立于1911年,总部位于上海。该公司旗下品牌妮维雅在市场上拥有很高的知名度和美誉度,是美白身体乳排名第一名,其品牌形

    2024-04-15
    9400
  • 伊贝诗水光透亮菁露怎么使用

    告别暗沉 水光透亮 拯救疲惫肌 我有bling瓶 28天肌肤焕亮一新 四大功效 1初步打底。初步打底鲜润肌底,轻轻一抹,水润满满。2打通通道。打通通道促进吸收,肌肤毛孔打开,后续成分更易吸收。3源头阻截。源头阻截亮肌晶采,添加3种焕

    2024-04-15
    9800

发表评论

登录后才能评论
保存