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.

Liam Barrett
  • 45
  • 1
  • 7
  • www.codebeach.com/2008/03/convert-color-image-to-gray-scale-image.html?m=1 – Theolodis Apr 14 '14 at 16:32
  • nice, looks good, ill give it a shot and let you know/mark the question answered – Liam Barrett Apr 14 '14 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 :( – Liam Barrett Apr 14 '14 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. – Liam Barrett Apr 14 '14 at 17:56

1 Answers1

7

Please try:

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

// ...

ImagePlus imp = IJ.getImage();
ImageConverter ic = new ImageConverter(imp);
ic.convertToGray8();
imp.updateAndDraw();
Kota
  • 191
  • 3