Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Can nobody help me???
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vicky  
View profile  
 More options Nov 11 2008, 10:38 am
Newsgroups: comp.soft-sys.matlab
From: Vicky <bonsa...@gmx.de>
Date: Tue, 11 Nov 2008 16:38:20 +0100
Local: Tues, Nov 11 2008 10:38 am
Subject: Can nobody help me???
Hallo there,

this is my code:

image1 = imread('image1.bmp');
image1 = im2bw(image1);
M = bwlabel(image1, 8);
imwrite(M, 'myImage.bmp');

How can I save an image (bmp), so that in each pixel is the element of
the matrice M?

If I save the matrice M with the command "imwrite" in each pixel of the
myImage.bmp is an rgb-value. But I don't want a rgb-value, I want the
label (element) of the matrice M.

How can I realize it?

Please I need help!!!

Best regards,
Vicky


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David  
View profile  
 More options Nov 11 2008, 10:53 am
Newsgroups: comp.soft-sys.matlab
From: "David" <d...@bigcompany.com>
Date: Tue, 11 Nov 2008 15:53:02 +0000 (UTC)
Local: Tues, Nov 11 2008 10:53 am
Subject: Re: Can nobody help me???

well, a bmp file is normally a simple rgb format.  read the help for imwrite and see if one of the other formats may be better for what you want.  or you may just want to save M to something else, like a mat file instead of as an image.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Chapman  
View profile  
 More options Nov 11 2008, 10:57 am
Newsgroups: comp.soft-sys.matlab
From: Adam Chapman <adam.chap...@student.manchester.ac.uk>
Date: Tue, 11 Nov 2008 07:57:41 -0800 (PST)
Local: Tues, Nov 11 2008 10:57 am
Subject: Re: Can nobody help me???
On Nov 11, 3:53 pm, "David" <d...@bigcompany.com> wrote:

Use the "save" command, and save the variable M in a .mat file

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Brown  
View profile  
 More options Nov 11 2008, 4:19 pm
Newsgroups: comp.soft-sys.matlab
From: Richard Brown <rgbr...@gmail.com>
Date: Tue, 11 Nov 2008 13:19:13 -0800 (PST)
Local: Tues, Nov 11 2008 4:19 pm
Subject: Re: Can nobody help me???
On Nov 12, 4:38 am, Vicky <bonsa...@gmx.de> wrote:

Hi Vicky

bwlabel creates a matrix of doubles (which imwrite assumes are between
0 and 1). If you convert it to an unsigned integer format, e.g

M = uint8(M)  % (or uint16, uint32, etc)

then saving to a bmp will probably give you what you want

cheers,

Richard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ImageAnalyst  
View profile  
 More options Nov 11 2008, 9:02 pm
Newsgroups: comp.soft-sys.matlab
From: ImageAnalyst <imageanal...@mailinator.com>
Date: Tue, 11 Nov 2008 18:02:02 -0800 (PST)
Local: Tues, Nov 11 2008 9:02 pm
Subject: Re: Can nobody help me???
On Nov 11, 10:53 am, "David" <d...@bigcompany.com> wrote:

---------------------------------------------
Correct.  Save in Tiff format instead.  It can take monochrome.
Regards,
ImageAnalyst

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vicky  
View profile  
 More options Nov 13 2008, 7:21 am
Newsgroups: comp.soft-sys.matlab
From: Vicky <bonsa...@gmx.de>
Date: Thu, 13 Nov 2008 13:21:12 +0100
Local: Thurs, Nov 13 2008 7:21 am
Subject: Re: Can nobody help me???
Hi ImageAnalyst,

Thank you for your answer.
I saved it in tiff format but I still get rgb-values.

This is my code:

image1 = imread('org_001.bmp');
image1 = im2bw(image1);
L1 = bwlabel(image1, 8);
imwrite(L1/255, 'image.tiff')

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.

What I'm doing wrong when saving?

Then I have a question. In my original rgb images are more than 256
colors. Is it still possible to create a monochrome image, so that each
color get a seperate label?

Can you please help me again?

Best regards,
Vicky

ImageAnalyst schrieb:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Walter Roberson  
View profile  
 More options Nov 14 2008, 1:52 pm
Newsgroups: comp.soft-sys.matlab
From: Walter Roberson <rober...@hushmail.com>
Date: Fri, 14 Nov 2008 12:52:59 -0600
Local: Fri, Nov 14 2008 1:52 pm
Subject: 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,uin t16(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)?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Image Analyst  
View profile  
 More options Nov 14 2008, 10:45 pm
Newsgroups: comp.soft-sys.matlab
From: "Image Analyst" <imageanal...@mailinator.com>
Date: Sat, 15 Nov 2008 03:45:03 +0000 (UTC)
Local: Fri, Nov 14 2008 10:45 pm
Subject: Re: Can nobody help me???

-------------------------------------------------------
OK, Vicky.  Run this code that I've posted before that will find blobs and label and measure them.  For you, I've adapted it to write out a tif image like you want, then i read it back in and display it with imtool so you can mouse around and inspect the values to verify that they are in fact the label values.
Regards,
ImageAnalyst

disp(' ');
disp('Running BlobsDemo.m...');
originalImage = imread('coins.png'); % Read in image
binaryImage = im2bw(originalImage, 0.4);       % Threshold to binary

subplot(3,2,1); imagesc(originalImage); colormap(gray(256)); title('Original Image');
subplot(3,2,2); imagesc(binaryImage); colormap(gray(256)); title('Binary Image');

labeledImage = bwlabel(binaryImage, 8);     % Label each blob so can do calc on it
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels

% Save the labeled image as a tif image.
imwrite(uint16(labeledImage), 'tif_labels.tif');
tifimage = imread('tif_labels.tif');
imtool(tifimage, []);  % Use imtool so she can inspect the values.

subplot(3,2,3); imagesc(labeledImage); title('Labeled Image');
subplot(3,2,4); imagesc(coloredLabels); title('Pseudo colored labels');

blobMeasurements = regionprops(labeledImage, 'all');   % Get all the blob properties.
numberOfBlobs = size(blobMeasurements, 1);

% bwboundaries returns a cell array, where each cell
% contains the row/column coordinates for an object in the image.
% Plot the borders of all the coins on the original
% grayscale image using the coordinates returned by bwboundaries.
subplot(3,2,5); imagesc(originalImage); title('Outlines');
hold on;
boundaries = bwboundaries(binaryImage);
for k = 1 : numberOfBlobs
        thisBoundary = boundaries{k};
        plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
hold off;

fprintf(1,'Blob #      Mean Intensity  Area     Perimeter  Centroid\n');
for k = 1 : numberOfBlobs           % Loop through all blobs.
        % Find the mean of each blob.  (R2008a has a better way where you can pass the original image
        % directly into regionprops.  The way below works for all versions including earlier versions.)
    thisBlobsPixels = blobMeasurements(k).PixelIdxList;  % Get list of pixels in current blob.
    meanGL = mean(originalImage(thisBlobsPixels));             % Find mean intensity (in original image!)
        blobArea = blobMeasurements(k).Area;            % Get area.
        blobPerimeter = blobMeasurements(k).Perimeter;          % Get perimeter.
        blobCentroid = blobMeasurements(k).Centroid;            % Get centroid.
    fprintf(1,'#%d %18.1f %11.1f %8.1f %8.1f %8.1f\n', k, meanGL, blobArea, blobPerimeter, blobCentroid);
end
msgbox('Finished running BlobsDemo.m.  Check out the figure window and the command window for the results.');


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vicky  
View profile  
 More options Nov 16 2008, 6:19 pm
Newsgroups: comp.soft-sys.matlab
From: Vicky <bonsa...@gmx.de>
Date: Mon, 17 Nov 2008 00:19:32 +0100
Local: Sun, Nov 16 2008 6:19 pm
Subject: Re: Can nobody help me???
Hi ImageAnalyst,

thank you very much for your help and the code.

Best regards,
Vicky

ImageAnalyst schrieb:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »