Thanks alot! you being really helpful: I want few explanation from you to understand few commands mentioned above!
1) B1 = logical(I1(:,:,1)*0); % is that command means reading the first row and column of red channel in I1 then in logical command 1 means true and 0 means false.....in this command it multiplied by 0 => what does that mean?
2) In loop shown below:
or i = 1:length(R)
B0 = abs(I1(:,:,1)-R(i)) < 20 & ... %absolute value of I1-R(i)
abs(I1(:,:,2)-G(i)) < 50 & ...
abs(I1(:,:,3)-B(i)) < 50;
B1 = B1 | B0;
% what does R(i) means and why we use <20, <50.....
what does B1 = B1 | B0 means
Apologise for asking so much, as I am new to image analysis and learning while I am processing the images through this platform! your help is much appreciated.
1) B1 = logical(I1(:,:,1)*0); % is that command means ...
No, it's just faster way to preallocate a matrix
[m,n,k] = size(I1); % I1 3d matrix
B1 = zeros(m,n); % B1 2d matrix (logical)
2) In loop shown below:
R(i) means red channel, G(i) means green channel, B(i) mean blue channel
You have different "blue" colors so i picked 3 of them:
R = [80 50 0];
G = [160 110 70];
B = [180 120 70];
Here is a simple example:
Imagine you have this image
i generated it using these command
[x,y,z] = peaks(50);
imagesc(z)
impixelinfo
Let's find colors in this region (value -6 approximately). How will you find them?
Let's find values
z1 = abs(z--6) < 2; % '2' is our tolerance
imshowpair(z1,z) % show images together
Green region is the region where values inbetween [-4 ... -8] ()
It's an example for gray image. Color image (RGB) has 3 matrices (Red, Green and Blue) so that is why i used tolerance for each channel.
Try to play with those values, see if you can detect better contour
3) what does B1 = B1 | B0 means
It means logical operand OR (simply '+'). As you can see we are searching for 3 colors (3 regions), so each for loop we are detecting different region. I want to merge them
Thank you for the explanation. I am nearly finish with this project. If you can help me by creating the loop which will count the pixels in the interface that will be great. I have attached the image...
Explanation: I have captured the interface of the dye by using the code we discuss above now i want to see the pixels in frame 15, 16 , 17 and see the change
perimeter! as perimeter explaining the rough estimation of amount of pixel in the interface and if you see in the attached cropframe15.png everything is white background except the perimeter so I want to explain in the code that colour of pixels in the perimeter are x y z hence count the pixels in the perimeter and give me the total number of pixels....
Sorry, I want the number of pixels in the contour (when you said perimeter I thought you mean number of pixels in boundary)..... I counted manually there are approximately 486 pixels. How would I can make a code of it to calculate them pixels.
I have attached you the image, which is basically the zoomed in image so one can count the pixels manually, but if I want to make a code for it how?
what you have explained above it is still very useful and cleared my thoughts regarding the pixels and parimeter calculations.
just wondering when I counted manually answer was 486 and with binarizing 431... differrence in pixels are like 55. Do you know why there is that difference?
sum(~A1(:)) => means it is adding all the pixels in the image except white background
Hamza please see the attached. I have changed to grey scale function to capture the contour of the injected dye flow but I am also getting the contours of other background is there a way to only capture the dye contour.
here is a code I used!
close all
clear all
clc
%Read the Image
I = imread('frame75.jpg');
I1 = imread('frame80.jpg');
warning('off', 'Images:initSize:adjustingMag');
%Convert to greyscale (contour command works on greyscale images)
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.