how i can find the blue object in the image by using the arrows in the picture ?
4 views (last 30 days)
Show older comments

the arrows has yellow dots ? how i can find the loctaion of these objects . I used the regionprobs to differentiate the objects . however, the intensoty level of yellow dots and its location i coudent reach it .
0 Comments
Answers (1)
Image Analyst
on 29 Feb 2020
You can find the blue region without the arrow, just find where the pixels have a blue signal but no red or green signal. If you need to follow the arrows, then you'll need to give some rules because the blue blob could be virtually anywhere, completely independent of the arrows. Do you need to find all blobs that could be intersected by a projection of the line from the last two arrows? What if it might point both to a blue blob and an earlier white or red blob? You'd have to find out which one is the blue blob. But if you're doing that, then why bother following the arrow anyway? Might there be lots of blue blobs, some of which might be intersected and some not intersected. I think you need to better define the problem before it could be answered. Otherwise, I could find the arrows but then also find the blue blob and essentially just ignore the arrows.
5 Comments
Image Analyst
on 29 Feb 2020
OK Mohammed, I'll give you a little more but I think you want the code to be yours rather than mine so we need to leave enough for you to do so that you feel at least a little bit of ownership of it, especially since it looks very much like a homework assignment.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
folder = pwd;
baseFileName = 'Treasure_easy.jpg';
% baseFileName = 'IMG_Segment_Success.JPEG';
fullFileName = fullfile(folder, baseFileName);
rgbImage = imread(fullFileName);
% Display the original image.
subplot(2, 3, 1);
imshow(rgbImage, []);
axis('on', 'image');
caption = sprintf('Original Color Image\n"%s"', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by Image Analyst', 'NumberTitle', 'Off')
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Get the red mask.
redMask = redChannel > 128 & greenChannel < 128 & blueChannel < 128;
subplot(2, 3, 4);
imshow(redMask);
grid on;
title('Red Mask', 'FontSize', fontSize, 'Interpreter', 'None');
% Get the white mask.
whiteMask = redChannel > 128 & greenChannel > 128 & blueChannel > 128;
% Display the image.
subplot(2, 3, 2);
imshow(whiteMask, []);
axis('on', 'image');
caption = sprintf('White Mask of \n"%s"', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Get the yellow mask.
yellowMask = redChannel > 128 & greenChannel > 128 & blueChannel < 128;
subplot(2, 3, 3);
imshow(yellowMask);
grid on;
title('Yellow Mask', 'FontSize', fontSize, 'Interpreter', 'None');
% Get the blue mask.
blueMask = redChannel < 128 & greenChannel < 128 & blueChannel > 128;
subplot(2, 3, 5);
imshow(blueMask);
grid on;
title('Blue Mask', 'FontSize', fontSize, 'Interpreter', 'None');
% Get the bounding boxes and centroid of the red arrows
propsR = regionprops(redMask, 'BoundingBox', 'Centroid');
% Get the bounding boxes and centroid of the white arrows
propsW = regionprops(whiteMask, 'BoundingBox', 'Centroid');
% Get the bounding boxes and centroid of the yellow spots
propsY = regionprops(yellowMask, 'BoundingBox', 'Centroid');
% Figure out what direction each white arrow is pointing.
subplot(2, 3, 3);
hold on;
for k = 1 : length(propsW)
thisBB = propsW(k).BoundingBox;
rectangle('Position', thisBB, 'EdgeColor', 'y', 'LineWidth', 1);
thisYellowCentroidX = propsY(k).Centroid(1);
thisYellowCentroidY = propsY(k).Centroid(2);
x1 = thisBB(1);
x2 = x1 + thisBB(3);
y1 = thisBB(2);
y2 = y1 + thisBB(4);
% Now find out where the yellow centroid lies within the bounding box.
end

See what you can do with this.
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!