I'm trying to use imfreehand and save the coordinates of my ROI so when I overlay the image onto another, that ROI is transparent (or set to NAN). Basically is there a way to set inside the imfreehand region as 'NaN' when I overlay onto another image? Reference attached image.
Here is my code:
%% output arrival_time parametric heatmap %%
figure;imagesc(at);colorbar;title('arrival time');
colormap('jet');caxis([2.5 5]);
%savefig(['Acute_1e13_draft_DRAFT_ignore' '.fig']);
%% code to blend heatmap %%
minv = 2.5;%min(min(R1_perf(:,:,29)));
maxv = 5;%max(max(R1_perf(:,:,2 t9)));
map=colormap('jet');
ncol = size(map,1);
s = round(1+(ncol-1)*(at-minv)/(maxv-minv)); % Taking arrival time values and rounding differences
rgb_at = ind2rgb(s,map);
rgb_at = imresize(rgb_at,5);
rgb_perf = ind2rgb(s,map);
rgb_perf = imresize(rgb_perf,5);
rgb_at_scale = imresize(rgb_at,[100 350],'nearest');
%rgb_at_scale_2 = imresize(rgb_at,[170 220],'nearest');
toto = zeros(size(rgb_at_scale));
%toto_2 = zeros(size(rgb_at_scale_2));
%toto(190:293,100:455,:) = rgb_at;
alpha = 0.65;
rgb_blend = fliplr(alpha * rgb_at_scale + (1 - alpha) * toto);
hFH = imfreehand();
% Create a binary image ("mask") from the ROI object.
binaryImage = hFH.createMask();
xy = hFH.getPosition;
structBoundaries = bwboundaries(binaryImage);
xy=structBoundaries{1}; % Get n by 2 array of x,y coordinates.
x = xy(:, 2); % Columns.
y = xy(:, 1); % Rows.
hold on; % Don't blow away the image.
plot(x, y, 'LineWidth', 2);
drawnow; % Force it to draw immediately.
% Burn line into image by setting it to 255 wherever the mask is true.
burnedImage = figure;
burnedImage(binaryImage) = nan;
imshow(burnedImage);
axis on;[![enter image description here][1]][1]