2

I am currently working on Connected Component Labelling. This is a process which takes an image and tells you how many separate objects are in the Image.

My problem is that at the very start I need to be able to take any image (specifically RGB value) and convert it into 8-bit.

EDIT: as in literally considered an 8bit, where the image is no longer recognised as RGB. Not an 8bit image that is recognised as an RGB.

Is there a way using code to automatically do this without having to go into the toolbar and convert it "manually"?

To clarify, I am programming for ImageJ using Java.

If anyone is willing to help me, I would be happy to provide them with the code I have so far where I am making a coloured image grey scale and then making it binary. My problem is that after the changes the image is still considered RGB, even though the image is essentially 8 bit.

Thanks

EDIT: I was looking at the code provided to me earlier and it doesn't seem to solve my problem. I am quite literally just wanting to make the little 'tick' that's next to RGB, be next to 8-bit instead. I have already done all the actual conversion on my own, its just still recognised as RGB image.

4
  • www.codebeach.com/2008/03/convert-color-image-to-gray-scale-image.html?m=1 Commented Apr 14, 2014 at 16:32
  • nice, looks good, ill give it a shot and let you know/mark the question answered Commented Apr 14, 2014 at 16:52
  • ok, im trying to do the grey scale version ( I put it in my main question) any idea what the colorImage is a reference too? I can get the rest of it working but theres no explanation for what this actually is exactly :( Commented Apr 14, 2014 at 17:02
  • unfortunately this seems to be how to do the part I can already do, and doesn't address the problem I am having where the image is still recognised as RGB. Commented Apr 14, 2014 at 17:56

1 Answer 1

7

Please try:

import ij.ImagePlus;
import ij.process.ImageConverter;

// ...

ImagePlus imp = IJ.getImage();
ImageConverter ic = new ImageConverter(imp);
ic.convertToGray8();
imp.updateAndDraw();
Sign up to request clarification or add additional context in comments.

1 Comment

ill give it a bash now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.