HeatMap attention 高亮显示

%load attention matrix,   h_img,img_h,p_h,h_p   9824*49*49
clear;
load('attention.mat');
%parameters
example_index = 2734;% matlab array index start from 1
h_word_index = 3;%the index of the key word in hypothesis
end_index =11;%the length of premise sentence

text_attention = h_p(example_index,h_word_index,1:end_index);
text_attention = reshape(text_attention,1,end_index);
text_attention = mapminmax(text_attention, -0.4, 1);
h = HeatMap(text_attention,'Colormap',gray);


image_name = '4455622662.jpg';

image_example = imread(image_name);
imshow(image_example);

image_size = size(image_example);

width = image_size(1,1);
height = image_size(1,2);

% attention resize
% image_attention = h_img(example_index,h_word_index,:);% keyword attention attention 1*1*49
% image_attention = reshape(image_attention,7,7)';      %7*7
% image_attention_norm_ori = mapminmax(image_attention, 0, 1);


load('img_norm_light.mat');

image_attention_norm = imresize(image_attention_norm_ori, [width height]);


% FlattenedData = image_attention(:)'; % 展开矩阵为一列,然后转置为一行。
% MappedFlattened = mapminmax(FlattenedData, 0, 1); % 归一化。
% image_attention_norm_ori = reshape(MappedFlattened, size(image_attention));
% image_attention_norm = imresize(image_attention_norm_ori, [width height]);
%heatmap
%imshow(image_attention_norm);
hmap = HeatMap(image_attention_norm);

im_cam_tri = zeros(width, height, 3);

im_cam_tri(:, :, 1) = image_attention_norm * 255;
im_cam_tri(:, :, 2) = image_attention_norm * 255;
im_cam_tri(:, :, 3) = image_attention_norm * 255;

% for k=1:3
% im_cam_tri(:,:,k)=flipud(im_cam_tri(:,:,k));%上下翻转
% end


new_image = double(0.05*image_example) + 0.95*(im_cam_tri);

figure;
imshow(new_image/255);

% new_image = double(image).* (im_cam_tri > 200);
% imshow(new_image/255);
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猴猴猪猪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值