- Home
- Search
- Contributors
- Recent Activity
- Flagged Content
- Log in to ask and answer questions.
- Ask a Question
- About MATLAB Answers

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by saam anand
on 2 Jan 2013

Hi, everybody. I am working on image processing of candle to find the length of the candle, flame and wick(Thread between candle and flame). Using gray scale image,In lab view, the parts of candle and flame are recognized but unable to find the length of the wick. For this I need to use color segmentation (math script)to recognize each part in the image. Could anyone suggest me a method for the above. Thanks in advance.

Answer by Image Analyst
on 3 Jan 2013

Accepted answer

Maybe you should try labview forums. This forum is just for MATLAB.

Show 34 older comments

saam anand
on 3 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120364

Thanks for your reply. I am looking for Image color segmentation in mat lab. Thank you.

Image Analyst
on 3 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120371

I give several color segmentation demos in my File Exchange. If you want more specific advice, you'll have to upload an image.

saam anand
on 3 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120437

http://inputcandle.blogspot.se/2013/01/hi-this-is-input-image.html

Hi, thanks for your reply. The above link shows the input image. for this image I need to segment the candle, flame and wick (thread between flame and candle) After segmentation the image should show three different parts. .

please suggest me a method. Thanks in advance.

Image Analyst
on 3 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120439

Why do you need to do this? What real world use does it have? Or is it your homework problem or semester project?

saam anand
on 3 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120444

Hi this is a part of my thesis work. I have worked on it, I was able to detect the edges of flame and candle but couldn't segment the wick. my task is to find the length of the candle, flame and wick as well. But I was not able to find the length of the wick. thank you.

Image Analyst
on 3 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120452

Since the wick is black and the background is black you can only find the lower end of the wick if it's on the candle. So find the candle, find its convex hull, look inside of that, threshold to find black, and look at the lowest part (largest row number). Finding the top part could be tougher. For this image you can find the flame and the candle and mask them out of the image. Then look at what's left and find the brightest part, assuming it's glowing. Then calculate the distance between the part on the candle and the part in the air. Since it's your graduate thesis I can't do much for you. Is it part of your Master's or Ph.D.? What is the main overall topic of your research that this is a small part of?

saam anand
on 3 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120461

Thank you. I will try with you suggestion. It's a part of my masters thesis work.

saam anand
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120869

Hi. http://www.blogger.com/blogger.g?blogID=3341042874737247183#allposts

The above method gives the length of the wick. But here i am using this in real time where I need to segment all the three objects. Finally I need to measure different parameters while the candle melts.The above link contains an image which was taken by using usb camera. In this image we can see the wick(Thread between candle and flame). I cannot detect the edges clearly. I have used all the filters but wasn't able to detect the edges of the three objects.could you please help me how to segment this.

Image Analyst
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120874

blogger.com won't let me see it unless I sign up for (create) a blog myself, which I don't want to do. It's not possible to find the area of the wick because it's black and your background is black. You'll have to be satisfied with the length. You can get the area of the flame and candle by traditional techniques (thresholding, color segmentation), but for the candle you'll probably want to take the convex hull and fill it in, but fill in just the part near the wick only, say, say limiting your fill area to just the top 20or 30 lines of the candle.

saam anand
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120884

Hi can you please tell me how to upload an image directly without using blogger.

Image Analyst
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120886

Try someplace like tinypic.com. Or see this link.

saam anand
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120895

Hi here is the link for the image from tinypic. http://tinypic.com/view.php?pic=b9hgd0&s=6

Here I am explaining my whole project clearly. I need to create a setup for a candle and measure various parameters during the melting process until it melts completely. I have created a VI in lab view which gives the parameters when an image is read. But that VI is working only for gray scale images and color segmentation can't be done. I need to segment the three objects and then I can call this M-file to lab view. Hope you understand my problem.

Image Analyst
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120896

I'd suggest changing the background from black to a vastly different color than anything else in the scene. Then it will be **a lot** easier.

saam anand
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120899

will it be a good idea to idea to use back light illumination, i.e. applying LED source from the background. so that the image might look more clear. please let me know your opinion.

Image Analyst
on 5 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_120902

No, I was thinking more like cyan or blue. Look at my avatar above and to the left, or here to pick a color that is as opposite to red, orange, and yellow as you can get.

saam anand
on 7 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121221

http://tinypic.com/r/2e2mcdu/6

Hi, the above link shows an example image with blue back ground.I need to do color segmentation to find the length of the wick. can you please suggest a method. If it works then i can take an image from real world and test it. thank you.

Image Analyst
on 7 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121225

That's no better - that's just a pseudocolored grayscale image. You need to put a paper with a different color behind the candle.

saam anand
on 7 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121257

http://tinypic.com/r/334u55c/6

Hi, the above link shows an image of a candle with light green(paper) background. can you suggest a method to segment.

Image Analyst
on 7 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121260

Yes! Much, much better. Simply extract all three color channels:

% Extract the individual red, green, and blue color channels. redChannel = rgbImage(:, :, 1); greenChannel = rgbImage(:, :, 2); blueChannel = rgbImage(:, :, 3);

Find where all three channels are dark

thresholdValue = 20; % Whatever... wick = (redChannel < thresholdValue) & ... greenChannel < thresholdValue) & ... blueChannel < thresholdValue);

saam anand
on 7 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121267

Hi, thank you. I have tried with the above code. I can see the wick. sorry for confusing you. I need to segment the input image as 3 parts, i.e, candle, wick and flame. If I can segment this the length and other parameters of the three segmented parts can be taken through VI in lab view.

Image Analyst
on 7 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121269

Same process. Just figure out what the thresholds need to be for each color channel. You might want to use a different color space if RGB is not working well for you, like HSV. See my File Exchange for demonstrations. By the way, you still haven't said what the larger topic of your thesis is that this is a small part of. What else are you working on? Because I know this is such a trivial task it can't be an entire thesis.

saam anand
on 7 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121316

I have created an environment to measure atmospheric temperature, sterain temparature,pressure through a PCB and in lab view all the parameters as I mentioned above. the total experiment is to give the better parameters for a candle with improved characteristics. this task may be extended further. Anyway thank you for your suggestion, I will try with that.

saam anand
on 9 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121640

Hi, I was trying to segment three parts using HSV model by using hsv model by varying the thresholds of hue, saturation and value. could you please tell me the threshold values of black and white colors.

Image Analyst
on 9 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121641

Black should have valueImage < 20 (or whatever). White should have valueImage > 200 (or whatever) and satImage < 20 (or whatever).

saam anand
on 9 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121696

could you please say how to use the values. While using HSV i need to specify thresholds for Hue, saturation and value for each color. I am sorry IF i confused you.

Image Analyst
on 9 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_121718

Did I not say how to use values? Like

blackWickPixels = valueImage < 20; % or whatever value works. candlePixels = valueImage>200 & saturationImage< 20;

Yes you have confused me. If you don't mean like the above, then what do you mean when you ask how you are supposed to use the values?

saam anand
on 12 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_122176

I am sorry. finally i got the desired result. credit goes to you and thank you.

saam anand
on 22 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_124297

Hi when I am reading the whole output segmented image into lab view, I am getting an error. for this I need to convert the output image to 2D(dimensional) array in matlab. From this array I can achieve the desired output. could you please help me with this. Thank you.

Image Analyst
on 22 Jan 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_124303

Just have a uint8 image where background pixels = 0, candle pixels = 1, wick pixels = 2, and flame pixels = 3. Write it out with imwrite().

saam anand
on 7 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_127867

Hi, when the above segmentation is working for 1 image, but in real time, I am not able to achieve the segmentation. I need to take several images while the candle is burning down and every time I have to change the threshold values for each image.This is becoming complex and uneasy to distinguish the images. could you please help me with any logic that it detects candle length(white part) as one component and then it goes to flame and wick.Here I am attaching one of my real time images.

http://tinypic.com/r/2ymbw2q/6. Thanks In advance.

Image Analyst
on 7 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_127869

Sorry, but to make it more robust would take more time than I can devote to your project.

saam anand
on 7 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_127877

Thanks for your reply. please try to help me with this. I will try but don't have enough experience. I can wait for few days, If you can give me an idea it would help me more than anything. Thank you.

saam anand
on 11 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_128711

Hi can you please suggest a method that detect and find the length of length of the candle and then wick and flame. Thank you.

Image Analyst
on 11 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_128781

This is how you gain experience. I simply don't have enough time to devote to making your project robust enough to handle all kinds of different images. That takes time. You get it working for some images, then another image comes along and it fails. Then you have to tweak the algorithm. It could take days or weeks. Sorry, but I can't do that for you.

saam anand
on 12 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_128969

Thanks for your reply. I will try.

tamanna
on 17 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_130187

hey..can u plz tel me how u segment the flame part?? actually i am working on an image in which i required to segment the convex part in an image..please help me out if u can

Image Analyst
on 17 Feb 2013

Link

**Direct link to this comment:**

http://www.mathworks.com/matlabcentral/answers/57813#comment_130193

I presume this is directed to saam, who probably has this completed by now.

- © 1994-2015 The MathWorks, Inc.
- Site Help
- Patents
- Trademarks
- Privacy Policy
- Preventing Piracy
- Terms of Use
- RSS
- Google+

- Featured MathWorks.com Topics:
- New Products
- Support
- Documentation
- Training
- Webinars
- Newsletters
- MATLAB Trials
- Careers

## 1 Comment

## Mmmm (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/57813#comment_182623

Can you please send me the part of your code where you are detecting flame. I am working on my school project and I am new in the MATLAB world so I am a little bit lost. I guess you can help me with this issue.