How do you make lines solid and/or thicker? How do you "split" an image by drawing a line at the desired location? Image Segmentation

8 views (last 30 days)
I'm trying to split up an image that I have into separate regions so I can then find the area of those separated regions. The code which I received help in making is shown below:
% % % % % COLOR ANALYSIS FOR SHELL COLOR % % % % %
% % % reads and crops % % %
f = imread('IMG_0001.jpg');
g = imcrop(f,[750 500 1800 1300]);
figure, imshow(g); title ('Cropped Image');
% % % Converts to BW Image to fill shell and cut out parts that are not shell % % %
burnedImage = g;
BW = im2bw(burnedImage, .5); % converts the truecolor image RGB to a binary image %
BW=~BW; % Inverse of the BW image %
filled = imfill(BW, 'holes'); % Fills the holes of the shell %
filled=~filled; % Inverse of the filled image %
figure, imshow(filled); title('Filled Black and White Image');
% % % DRAW LINES % % %
burnedImage = filled;
% % % Line1 % % %
hLine = imline();
binaryImage1 = hLine.createMask();
burnedImage(binaryImage1) = 255;
imshow(burnedImage); title('BurnedImage1');
% % % Line2 % % %
hLine=imline();
binaryImage2 = hLine.createMask();
burnedImage(binaryImage2) = 255;
imshow(burnedImage); title('BurnedImage2');
% % % Line3 % % %
hLine=imline();
binaryImage3 = hLine.createMask();
burnedImage(binaryImage3) = 255;
imshow(burnedImage); title('BurnedImage3');
% % % Line4 % % %
hLine=imline();
binaryImage4 = hLine.createMask();
burnedImage(binaryImage4) = 255;
imshow(burnedImage); title('BurnedImage4');
% % % Line5 % % %
hLine=imline();
binaryImage5 = hLine.createMask();
burnedImage(binaryImage5) = 255;
imshow(burnedImage); title('BurnedImage5');
set( findobj(gcf,'type','line'), 'LineWidth', 500);
burnedImage = ~burnedImage;
figure, imshow(burnedImage); title('Image for Analysis');
% % % Find Area of each Region % % %
STATS = regionprops(burnedImage, 'Area');
allArea = [STATS.Area]
% % % % % Optional % % % % %
% A = numel(burnedImage(burnedImage==0)) % % % Counts off Pixels % % %
% B = numel(burnedImage(burnedImage==1)) % % % Counts on Pixels % % %
I am trying to find the area of only the shell of the turtle (you can use this link to see the images, http://www.facebook.com/pages/Terrapin-Station-and-Freshwater-Turtles/118675974883450 -they are the recently added turtle images). I was helped in making this code, and was told to use the method in the previous code to separate the head, legs, and tail from the shell body of the turtle. The problem is that when I draw the lines, they show up dotted, and dont actually separate the regions... Any help would be greatly appreciated! Thanks!
  4 Comments
Dimitri
Dimitri on 23 Jan 2013
I was just trying to show what I was doing since it can be a little hard to explain/understand. But if you'd like I will remove it. My problem lies only with the first part/post.
Dimitri
Dimitri on 23 Jan 2013
What i've done to "patch" the problem (not really fix), is that instead of only drawing 5 lines, I rewrite:
hLine = imline();
binaryImage1 = hLine.createMask();
burnedImage(binaryImage1) = 255;
imshow(burnedImage); title('BurnedImage1');
about 20 times, and just zoom and put additional lines next to the others to make a thicker line that shows up as solid. Being able to avoid this would be a really big time saver though.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 23 Jan 2013
You can use imdilate() on the binaryImage1 to thicken the line before burning it into the image.

More Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!