i4info Provides the best hacking Material. Latest hacking tutorials and tools are available here. It is the best place for hackers.

Latest topics

» Infographic Resume Template two colors [PSD and Word]
Mon Mar 06, 2017 6:13 pm by Admin

» BitCoin Wallet stealor New
Sun Feb 19, 2017 7:52 pm by jammieban

» The Omega Organisation is looking for members
Sun Feb 19, 2017 5:50 pm by TheOmegaOrg

» Hack any Facebook Account for Free
Thu Feb 16, 2017 2:25 pm by Admin

» Teen Patti Gold Hack & 3 Patti Chips Code Extra Bonus 2016
Sun Feb 12, 2017 12:13 pm by Shan Soomro 51

» Hallmarks of Scientific Research
Fri Feb 10, 2017 4:04 pm by Nomi gee

» Hotspot Shield Elite VPN [Latest]
Sun Jan 29, 2017 11:52 am by Admin

» CCleaner Professional Plus [Latest]
Sun Jan 29, 2017 9:32 am by harry756

» SQL Dumper v.8.0
Fri Jan 13, 2017 10:18 pm by imsopickled

March 2017


Calendar Calendar


free forum

Forumotion on Facebook Forumotion on Twitter Forumotion on YouTubeForumotion on Google+

Visitors Counter

Flag Counter

Color Detection on Images by Using MATLAB


Posts : 473
Reputation : 7
Join date : 2014-12-10
Age : 24
Location : Pakistan

Color Detection on Images by Using MATLAB

Post by Admin on Sun Jun 05, 2016 5:06 pm

Color Detection in Image by using MATLAB


Hi everyone, I hope you are doing fine, Today I will share teach you how to detect images in MATLAB, in order to do so, I will share a step by step guide for Color Detection in MATLAB. I will share a project with you for better understanding and learning.
[You must be registered and logged in to see this link.]

  • So as to do the Color Recognition in Images utilizing MATLAB, first of all, we require a Picture.


  • Therefore, I Designed a picture in paint that has diverse shapes in various hues as appeared in beneath picture:
    [You must be registered and logged in to see this link.]

  • There are distinctive shapes and colors in the picture, we will distinguish these shapes by their colors.


  • Copy/Paste the give code into your m File.



   data = imread('TEP.jpg');
   diff_im = imsubtract(data(:,:,2), rgb2gray(data));
   %Use a median filter to filter out noise
   diff_im = medfilt2(diff_im, [3 3]);
   diff_im = im2bw(diff_im,0.18);
   diff_im = bwareaopen(diff_im,300);
   bw = bwlabel(diff_im, Cool;
   stats = regionprops(bw, 'BoundingBox', 'Centroid');
   % Display the image
   hold on

   for object = 1:length(stats)
       bb = stats(object).BoundingBox;
       bc = stats(object).Centroid;
       plot(bc(1),bc(2), '-m+')
       a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
       set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'black');
   hold off


  • After implementing the code, Execute the m file, if there is no error, you will get the output.
    [You must be registered and logged in to see this link.]
    You can find in the above figure, we have just recognized the shapes with green shading.

  • The + sign demonstrates the focal point of each distinguished shape.

  • X and Y are the x,y directions of the mid point of every shape that are appeared in dark for every recognized shape.

  • Presently, We have distinguished red Shapes in the Pic, so keeping in mind the end goal to do as such what I have to do is to just change the third esteem in imsubtract capacity from 2 to 1.

Download the complete code for Color detection.

Download Full Code

  • If you run this code in MATLAB, then your output will be like that:

  • Now, it recognized the red shapes/Objectives in MATLAB.


  • Its x,y coordinates are in Dark Color.
    [You must be registered and logged in to see this link.]
    In the end we will identify the blue shading, to do so, you simply have to change the third parameter to 3 and it will distinguish the blue shading like this:


That’s all for now, I hope it will help you a lot, For any kind of help ,about Color detection on image with MATLAB, Comment Below.

    Current date/time is Sat Mar 25, 2017 2:53 am