Help regarding Image Segmentation of B/W Image!!
Show older comments
Hello! I am working on a project titled 'Yarn Hairiness determination using Image Processing'. The steps involved are- Image processing and Image analysis. In the processing, I converted the image to B/W. After that I am suppose to segment the core yarn from the its protruding fibres. I am stuck here. I have attached the the picture below. It would be a big help!
5 Comments
Image Analyst
on 14 Mar 2015
Edited: Image Analyst
on 14 Mar 2015
Please attach the image so we can help you. Maybe you forgot to click "Attach file" after you browsed to the image??? Better yet, just use the brown and green frame icon to insert the image into the body of your message.
Samkit Mutta
on 20 Mar 2015
Samkit Mutta
on 20 Mar 2015
Image Analyst
on 20 Mar 2015
Yes, they do look different: different color, different fiber composition, different amounts of fray, different thread diameter, etc. Exactly what do you want to characterize in the two images?
Samkit Mutta
on 23 Mar 2015
Accepted Answer
More Answers (3)
Meghana Dinesh
on 20 Mar 2015
0 votes
Try using the Morphological operators dilation and erosion.
4 Comments
Samkit Mutta
on 23 Mar 2015
Meghana Dinesh
on 27 Mar 2015
Maybe you can use spur and then subtract the Images (before and after spur) and improve on this to get your second requirement.
Samkit Mutta
on 27 Mar 2015
Samkit Mutta
on 29 Mar 2015
Image Analyst
on 23 Mar 2015
0 votes
Simply try thresholding. See my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 You might also like my demo for how to extract the largest blob, attached.
Samkit Mutta
on 19 Apr 2015
0 votes
26 Comments
Image Analyst
on 19 Apr 2015
That's the way MATLAB works. If you run a script, you put variables into the base workspace. Each function has it's own private workspace that comes into existence when you enter the function and goes away when you leave the functions. I'm sure you've heard of "garbage collection" in java. So to see any variables in a function, you have to set a breakpoint in that function. The reason I did a function instead of a script was that I could then put all the functions in the same m-file. You can't have a script followed by a function in the same m-file so if I had a script, I would have to have had at least two m-files, not one.
Samkit Mutta
on 19 Apr 2015
Image Analyst
on 19 Apr 2015
Put this line of code into your code:
workspace; % Make sure the workspace panel is showing.
Samkit Mutta
on 19 Apr 2015
Image Analyst
on 19 Apr 2015
Then why do you say the workspace does not show up? Put a breakpoint on that line of code and see if the workspace panel shows up when you execute the line of code. And if it does, step through the code to see when the workspace panel vanishes. Of course if you step out of a function, the workspace panel will now show the parent routine's variables, but the panel should still be there.
Samkit Mutta
on 20 Apr 2015
Image Analyst
on 20 Apr 2015
Are you sure you don't have a "clear" or "clear all" or "clearvars" in there somewhere?
Samkit Mutta
on 20 Apr 2015
Image Analyst
on 21 Apr 2015
I don't have that problem. I set a breakpoint there and, and you can see in the screen capture below, you can clearly see the workspace panel on the left with the variables showing up inside it. If you don't see that, call the Mathworks.

Samkit Mutta
on 21 Apr 2015
Image Analyst
on 21 Apr 2015
I did not set any breakpoints. I just let the code run uninterrupted. So the workspaces popped into being while the function was being executed, and vanished when the functions exited, just like they're supposed to. You can't see the workspaces while the function is executing with no breakpoints - it simply doesn't need to display them because it doesn't need to since there's no way you could examine them anyway. You can only see and examine the workspace variables when you have set a breakpoint and stopped at it.
Samkit Mutta
on 21 Apr 2015
Samkit Mutta
on 21 Apr 2015
Image Analyst
on 21 Apr 2015
What is the favor or question?
Samkit Mutta
on 22 Apr 2015
Image Analyst
on 22 Apr 2015
Here's a snippet on inputdlg():
% Ask user for two floating point numbers.
defaultValue = {'45', '67'};
titleBar = 'Enter a value';
userPrompt = {'Enter number 1 : ', 'Enter number 2: '};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValue);
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
% Convert to floating point from string.
usersValue1 = str2double(caUserInput{1})
usersValue2 = str2double(caUserInput{2})
% Check for a valid integer.
if isnan(usersValue1)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
usersValue = defaultValue;
message = sprintf('I said it had to be a number.\nI will use %f and continue.', usersValue1);
uiwait(warndlg(message));
end
and I'm sure you know how to use and "if" statement to compare numbers.
Samkit Mutta
on 23 Apr 2015
Samkit Mutta
on 23 Apr 2015
Edited: Samkit Mutta
on 23 Apr 2015
Image Analyst
on 23 Apr 2015
Try this:
hairareaindex = .5; % The ACTUAL hair index.
% Ask user for hte acceptable value.
prompt={'Enter the acceptable Hair Area Index'};
dlg_title='Input';
userResponse = inputdlg(prompt,dlg_title)
acceptableHairIndex = str2double(cell2mat(userResponse))
if acceptableHairIndex <= hairareaindex
message = sprintf('The actual hair index of %f is above the acceptable value of %f, so this yarn IS Acceptable',...
hairareaindex, acceptableHairIndex);
uiwait(msgbox(message));
else
message = sprintf('The actual hair index of %f is below the acceptable value of %f, so this yarn IS NOT Acceptable',...
hairareaindex, acceptableHairIndex);
uiwait(warndlg(message));
end
Samkit Mutta
on 27 Apr 2015
Samkit Mutta
on 27 Apr 2015
Image Analyst
on 27 Apr 2015
You're welcome. I'm glad I could help you towards a successful project. If you want, you can also "Vote" for my two answers to give me "reputation points".
sudha muthusamy
on 14 Jul 2018
image analyst sir, i am also doing same sort of project ,can u help me to work this in 3d yarn image .
sudha muthusamy
on 14 Jul 2018
sir is this possible for a moving yarn ??
sudha muthusamy
on 14 Jul 2018
sir please provide an idea related to yarn hairiness measurement
Image Analyst
on 14 Jul 2018
Categories
Find more on Image Preview and Device Configuration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


