Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Image Processing - Matlab

Status
Not open for further replies.

apoorvmintri

Newbie level 4
Joined
May 25, 2011
Messages
6
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,331
Hi,


Trying to learn image processing myself on Matlab by doing some online tutorials. I encountered a problem and would like to know how to do it.

In an image if there is dust/smoke. How do I calculate it's density (no. of pixels with dust or smoke compared to the total no. of pixels)? And evaluate it's intensity and color content of dust/smoke?

For example, how would you code to find the no.of pixels that have smoke and its intensity/color content of this below image-
smokyimage.png
 

I did some work, and it seems good but can anyone help me further?
So first I converted the image to HSV, and threshold the S<=0.1
Matlab Code
f = imread('smokyimage.bmp');
[m n k] = size(f);
fs = rgb2hsv(f);
H = fs:),:,1);
S = fs:),:,2);
V = fs:),:,3);
for i=1:m
for j=1:n
if S(i,j)<=0.1
S(i,j)=0;
else
S(i,j)=1;
end
end
end
fshsv = cat(3,H,S,V);
ff = hsv2rgb(fshsv);

This provided me with the image below, how should I go on about it?
untitled.png
 
nice. from there you can start counting the red pixels based on the RGB function, image(x,y,1:3)... where x and y is their coordinates while 1:3 will tell the RED, GREEN and BLUE values.
since you want the RED pixels, then you can select your RED threshold values and count those pixels.

Code:
count = 0;
for i=1:m
    for j=1:n
        red = ff(i,j,1);
        if red >= 0.5
            count = count + 1
        end
    end
end
 
Thanks Miskol, it worked!
Though I just figured something - the code is working perfectly for images 1360x1024 but not for 816x614.
In 816x614 it misses out some of the smoke. Any ideas?
 

can share example image for 816x614?
 

Hey Miskol,

I realized that the problem isn't the image size, its due to the varied intensities in the picture. Hence I equalized the histogram of the intensity, using the HISTEQ command on matlab. And it worked perfectly! Thanks a lot man =D

apoorvmintri
 

no problem, glad to have helped.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top