Re: Can nobody help me???
- From: Walter Roberson <roberson@xxxxxxxxxxxx>
- Date: Fri, 14 Nov 2008 12:52:59 -0600
Vicky wrote:
In each pixel is an rgb value like (8, 8, 8) or (12, 12, 12). But I want that in each pixel is the label like 1, 2,...8,...12,...
That means that in each pixel should be a single scalar value and not the color.
I'm not clear on what you are asking. With your repetitions of the fact that you
want each pixel to be the "label" and not the colour, then it sounds like what you
want to produce is an image in which everywhere that the original image would
have been labeled with 1, the new image would show the -character- 1, and so
on -- an image composed of text drawn in to the appropriate places.
If your goal was just to store binary data corresponding to the label, then
it is not clear why you would bother to store it in an image file, but there is
some hidden Very Good Reason For This, then create a new matrix which is
NewImageG = uint16(LabelMatrix);
and write that out using 'png' or 'ppm' or 'jpg' format. You may need
to use the jpg options
'Bitdepth', 16, 'Mode', 'lossless'
If you -must- use BMP for your purposes, then if L is your label matrix:
L16 = uint16(L);
Lrgb = cat(3,zeros(size(L16),'uint8'),uint8(bitshift(L16,-8)),uint8(bitand(L16,uint16(255))));
imwrite(Lrgb, 'FileName.bmp');
and to read the values back in:
Lrgb = imread('FileName.bmp');
L = bitor(bitshift(uint16(Lrgb(:,:,2)),8),uint16(Lrgb(:,:,3)));
This code would need some minor adjustment if you have more than 65535 labels.
--
..signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?
.
- References:
- Can nobody help me???
- From: Vicky
- Re: Can nobody help me???
- From: David
- Re: Can nobody help me???
- From: ImageAnalyst
- Re: Can nobody help me???
- From: Vicky
- Can nobody help me???
- Prev by Date: Re: reading complex marix from file
- Next by Date: Re: GCB/GCBH calls not selecting current Simulink block
- Previous by thread: Re: Can nobody help me???
- Next by thread: Re: Can nobody help me???
- Index(es):
Relevant Pages
|