From: Sami Oueslati on 24 Mar 2010 19:59 Thank you for accepting to help Here's the link: http://drop.io/mqlwmho# There's an image which resumes the steps to follow and a file named M1.fig which represents the white bands. I'll work by my side, if I find a solution, I tell you!!!
From: ImageAnalyst on 24 Mar 2010 20:15 Sami: Here's an example, but it may need a little checking to see if the center line is where you want it in cases where your stripe is an even number of lines (for example, where would you put the centerline if this were your stripe [127 127 255 255 255 255 127]? Would you put your black stripe (value of 0) at element 4 or 5? clc; % Clear the command window. close all; % Close all figures (except those of imtool.) clear all; % Erase all existing variables. workspace; % Make sure the workspace panel is showing. % Read in standard MATLAB demo image. grayImage = imread('tire.tif'); subplot(2,2, 1); imshow(grayImage, []); title('Original Grayscale Image'); set(gcf, 'Position', get(0,'Screensize')); % Maximize figure. % Binarize the image by thresholding it. thresholdValue = 204; binaryImage = grayImage > thresholdValue; subplot(2,2, 2); imshow(binaryImage, []); title('Binary Image'); [rows columns numberOfColorBands] = size(grayImage); % Prepare a Stripe image. Background = 127. % Stripes will be 255, and black centerlines will be 0. stripedImage = uint8(127 * ones(rows, columns)); stripedImage(:, max(binaryImage,[],1) > 0 ) = 255; subplot(2,2, 3); imshow(stripedImage); title('Vertical stripes'); axis on; % Get the horizontal profile. horizontalProfile = (max(binaryImage) == 1); % Find where stripe start and stop. stripeEdges = diff(horizontalProfile); % Find where stripe start. stripeStarts = find(stripeEdges == 1); % Find where stripe start. stripeEnds = find(stripeEdges == -1); % Find where middles of stripes are. centerLines = round((stripeStarts + stripeEnds) / 2); % Create image to hold stripes plus black centerlines. binaryImage2 = stripedImage; % Assign stripes binaryImage2(:, centerLines) = 0; % Assign black centerlines. subplot(2,2, 4); imshow(binaryImage2, []); title('Vertical Stripes with black Center Lines');
From: Sami Oueslati on 25 Mar 2010 05:02 Thanks again ImageAnalyst...I'm agreeably surprised..How you make it with so much easiness??!! But there's a little problem...I think that when the binaryImage starts with a white line, the centerline won't pass by the middle of each white stripe but in this case, by the middle of each black one. the image that you chose starts with a black line, that's why it worked... Hope you understand what I mean in spite of my poor english... if (stripeStarts + stripeEnds = uneven): doesn't matter which position takes the centerline. I'm feeling bad cause I think I'm abusing of your generosity... Sami. ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <074bd7e7-2459-4cd8-b285-2339cbe30e25(a)b7g2000yqd.googlegroups.com>... > Sami: > Here's an example, but it may need a little checking to see if the > center line is where you want it in cases where your stripe is an even > number of lines (for example, where would you put the centerline if > this were your stripe [127 127 255 255 255 255 127]? Would you put > your black stripe (value of 0) at element 4 or 5? > > clc; % Clear the command window. > close all; % Close all figures (except those of imtool.) > clear all; % Erase all existing variables. > workspace; % Make sure the workspace panel is showing. > % Read in standard MATLAB demo image. > grayImage = imread('tire.tif'); > subplot(2,2, 1); > imshow(grayImage, []); > title('Original Grayscale Image'); > set(gcf, 'Position', get(0,'Screensize')); % Maximize figure. > > % Binarize the image by thresholding it. > thresholdValue = 204; > binaryImage = grayImage > thresholdValue; > subplot(2,2, 2); > imshow(binaryImage, []); > title('Binary Image'); > > [rows columns numberOfColorBands] = size(grayImage); > % Prepare a Stripe image. Background = 127. > % Stripes will be 255, and black centerlines will be 0. > stripedImage = uint8(127 * ones(rows, columns)); > stripedImage(:, max(binaryImage,[],1) > 0 ) = 255; > subplot(2,2, 3); > imshow(stripedImage); > title('Vertical stripes'); > axis on; > > % Get the horizontal profile. > horizontalProfile = (max(binaryImage) == 1); > % Find where stripe start and stop. > stripeEdges = diff(horizontalProfile); > % Find where stripe start. > stripeStarts = find(stripeEdges == 1); > % Find where stripe start. > stripeEnds = find(stripeEdges == -1); > % Find where middles of stripes are. > centerLines = round((stripeStarts + stripeEnds) / 2); > % Create image to hold stripes plus black centerlines. > binaryImage2 = stripedImage; % Assign stripes > binaryImage2(:, centerLines) = 0; % Assign black centerlines. > subplot(2,2, 4); > imshow(binaryImage2, []); > title('Vertical Stripes with black Center Lines');
From: ImageAnalyst on 25 Mar 2010 06:11 Yes, I realized that, along with the even number issue. But I didn't feel like putting more time into it to handle the boundary issue. I'm sure you can handle that. Perhaps one way is to just enlarge the array on the sides with one column so the stripe is not at the edge anymore, then crop when you're all done. I'm sure you can figure it out just as well as I can - it's not really that hard.
From: Sami Oueslati on 25 Mar 2010 06:35 Ok I will see that and when the strips are in a horizontal way...how I do that??? Is there a function for rows like 'diff' for columns????? Thanks. ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <f0cf5a85-fcc2-4a5c-8e20-a7a5cb33cdf2(a)k19g2000yqn.googlegroups.com>... > Yes, I realized that, along with the even number issue. But I didn't > feel like putting more time into it to handle the boundary issue. I'm > sure you can handle that. Perhaps one way is to just enlarge the > array on the sides with one column so the stripe is not at the edge > anymore, then crop when you're all done. I'm sure you can figure it > out just as well as I can - it's not really that hard.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Using Trapz function Next: plotting equi-distant points given 4 coords points |