Re: Can nobody help me???



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)?
.



Relevant Pages

  • Re: Fontheigt = Zeilenhöhe
    ... danke für den Tip mit dem Label - geht aber nicht, ... Was das "fotografieren" und auszählen der Pixel angeht: ... Feldinhalte breiter als die Breite der Editbox -> "überlauf"... ...
    (microsoft.public.de.fox)
  • Re: Label Caption Truncates
    ... destination label / textbox EXCEPT: ... Having said that, reading the TextWidth of a string by placing it in a Autosize Label Control with the Label set to the desired font attributes and reading the resultant Width of the Label is one of the many available ways of effectively reading the TextWidth of the string, although of course it will only return the correct size if the text is going to be displayed or drawn onto another screen object and not onto something else with different characteristics, such as a printer. ... It should be remembered though that the TextWidth function tells you the width of the "row of character cells" that the string will occupy when printed, and so if actual printed width is important to you (the distance between the leftmost pixel plotted and the rightmost pixel plotted) then you need to take other things into account as I mentioned in my earlier response, because the actual printed pixel width can be either smaller or greater than the TextWidth, depending on the font used and the specific characters used at the left and right ends of the string. ...
    (microsoft.public.vb.general.discussion)
  • Re: Audio Metering implementation
    ... I am currently implementing a software Audio Meter that visualizes the ... pixel difference between each unit is the same. ... You must understand something about logarithms in order to express the signal magnitudes as logarithms. ... Plot the signal without taking logs, then label the points with their ...
    (comp.dsp)
  • GDI and visual c++ problem...
    ... 1)Does anynone know how can I display the pixel value and the pixel format of ... a bitmap file ?I want for example to load a bitmap in a picture box and ... 2)How can I change a form propertie (for example a label) by a class that is ...
    (microsoft.public.dotnet.languages.vc)