Clear Filters
Clear Filters

How can I extract the region of interest and its features of the highest moving energy/intensity area

5 views (last 30 days)
The following is a part of images (video) that taken in an experiment
How can I only take into consideration the highest moving energy/intensity area that keeps moving and discard the rest of the image?
I mean I want only to extract the region of interest (the highest moving energy/intensity area) and its features?
I have multiple experiments (around 60000) and I want to do the same for all of them
Note: When you run it as a video you will notice the area
Note that the ROI alawys has more events (more density), this will help to avoid annotation process
load ('data.mat')
for i = 1:201
imshow(data(:,:,:,i),[]);
pause(0.001)
end

Answers (2)

Image Analyst
Image Analyst on 11 Dec 2023
The Computer Vision Toolbox has tracking functions in it. Look into them.
  7 Comments
M
M on 14 Dec 2023
Edited: M on 14 Dec 2023
@Image Analyst Thanks, could you please tell me what is the best way to choose the threshold
If you don't want interior holes considered as part of the area, we'll have to do additional operations.
Could you please suggest to me how can this be done? because I am not interested in the interior holes, (just to make sure, you meant by holes the inside black holes right?
Also, please clarify the purpose of calculating centroid, xy and areas

Sign in to comment.


Image Analyst
Image Analyst on 14 Dec 2023
Try this:
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
markerSize = 20;
%--------------------------------------------------------------------------------------------------------
% READ IN TEST IMAGE
folder = pwd;
baseFileName = "m's image.png";
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get size
[rows, columns, numberOfColorChannels] = size(grayImage)
% Convert to grayscale if it is not already.
if numberOfColorChannels == 3
grayImage = grayImage(:, :, 2);
end
% Get rid of white frame around the image.
allWhiteRows = all(grayImage == 255, 2);
allWhiteColumns = all(grayImage == 255, 1);
grayImage = grayImage(~allWhiteRows, ~allWhiteColumns);
% Display the image.
subplot(2, 2, 1);
imshow(grayImage);
axis('on', 'image');
impixelinfo;
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
%--------------------------------------------------------------------------------------------------------
% Get vertical profile
verticalProfile = sum(grayImage, 2);
% Display the profile.
subplot(2, 2, 3);
plot(verticalProfile, 'b-');
grid on;
% Erase rows with integrated gray levels less than 500 to make sure the blobs are separated.
grayImage(verticalProfile < 500, :) = 0;
%--------------------------------------------------------------------------------------------------------
% Threshold the image.
binaryImage = grayImage >= 1;
%--------------------------------------------------------------------------------------------------------
% Display the image.
subplot(2, 2, 2);
% imhist(grayImage);
imshow(binaryImage, []);
impixelinfo;
axis('on', 'image');
title('Initial Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Maximize window.
g = gcf;
g.WindowState = 'maximized';
g.Name = 'Demo by Image Analyst';
g.NumberTitle = 'off';
drawnow;
%--------------------------------------------------------------------------------------------------------
% Call a closing to fill in and connect some small blobs.
se = true(3, 15);
binaryImage = imclose(binaryImage, se);
% Take the largest 3 blobs.
binaryImage = bwareafilt(binaryImage, 3);
% Fill holes.
binaryImage = imfill(binaryImage, 'holes');
% Display the image.
subplot(2, 2, 3);
imshow(binaryImage, []);
impixelinfo;
axis('on', 'image');
title('Final Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
%--------------------------------------------------------------------------------------------------------
% Get area weighted by shape of outline.
area1 = bwarea(binaryImage)
% Get areas as a simple pixel count.
props = regionprops(binaryImage, 'Area');
area2 = [props.Area]
% Display the original image.
subplot(2, 2, 4);
imshow(grayImage);
axis('on', 'image');
hold on;
% Get the boundary of the mask.
boundaries = bwboundaries(binaryImage);
% Display the outline over the original image.
visboundaries(boundaries, 'Color','r', 'LineWidth',1);
caption = sprintf('Total Area of all %d blobs = %.1f pixels', numel(props), area1)
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!