Help with grain boundaries and smoothing

184 views
Skip to first unread message

mam...@cornell.edu

unread,
Sep 30, 2018, 4:45:24 AM9/30/18
to MTEX
Hi, 
I'm trying to create grain boundaries and smooth my data. The sample is an odd shape, as it is surrounded by resin. The non-indexed areas in the middle of the sample are amorphous. 
How can I stop the grain boundaries from (1) indexing outside the edges of my sample and (2) drawing grains in the middle areas that I know are amorphous? (See attachments)
Any suggests are greatly appreciated! 
WLT_S1_site6.jpeg
WLT_S1_site6_grains.tif

Ralf Hielscher

unread,
Sep 30, 2018, 4:54:01 AM9/30/18
to MTEX
Have you had a look here:


it tells you that 

grains = calcGrains(ebsdP('indexed'),'boundary','tight')

prevents these artifacts at the outside and also gives some hints how to deal with the armorphic regions in the inside. If this does not help, you may want to share your script and/or the data.

Ralf.

MTEXNewbie

unread,
Oct 23, 2018, 6:16:21 AM10/23/18
to MTEX
I have a similar problem like above, MTEX is filling the holes inside my sample.

[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd('indexed'),'angle',2.5*degree,'boundary','tight');

I have went through the grain reconstruction document but it did not help to retain the holes - https://mtex-toolbox.github.io/files/doc/GrainReconstruction.html

ruediger Kilian

unread,
Oct 23, 2018, 12:10:00 PM10/23/18
to 'Dwayne' via MTEX
Hi,
how about using all pixels to calculate grains, not only the 'indexed' ones?
Cheers,
Rüdiger

MTEXNewbie

unread,
Oct 24, 2018, 5:30:46 AM10/24/18
to MTEX
Hi Rüdiger,

It worked!

But now there is a box showing up surrounding the EBSD map (not the box property of figure), is there a way to remove that box?

ruediger Kilian

unread,
Oct 24, 2018, 5:36:24 AM10/24/18
to mtex...@googlegroups.com
Can you be a little bit more specific about your box?

Cheers,
Rüdiger

MTEXNewbie

unread,
Oct 24, 2018, 6:05:41 AM10/24/18
to MTEX
Here is a screenshot of the orientation map accounting all pixels - https://i.imgur.com/sjAzAbd.jpg

The inclined box was not present with ebsd('indexed').

ruediger Kilian

unread,
Oct 24, 2018, 6:17:39 AM10/24/18
to mtex...@googlegroups.com
Looks rather as a map with some boundaries to me. Which boundaries are you plotting? All? Or only those of the indexed phase?
Cheers,
Rüdiger

MTEXNewbie

unread,
Oct 24, 2018, 6:28:41 AM10/24/18
to MTEX
grains below contains data for all pixels (indexed and non-indexed).

% plot the data
plot(ebsd,ipfKey.orientation2color(ebsd('indexed').orientations),'micronBar','off','figSize','medium')
hold on
plot(grains.boundary,'linewidth',1)
hold off

> Which boundaries are you plotting? All? Or only those of the indexed phase? 

it would be all boundaries since grains here means all pixels, I have amended the code based on the above comment and the box is gone now.

plot(grains('indexed').boundary,'linewidth',1)

Is that a good solution or is there a better way to do it?

MTEXNewbie

unread,
Oct 26, 2018, 9:24:58 AM10/26/18
to MTEX
Hi Rüdiger,

After using all pixels to calculate grains, there are some warnings for one of the sample. I have not used the INPOLYGON command in the script.


Warning: The results from INPOLYGON may not be reliable. The size of the
polygon is approaching the upper limit of what can be handled with
reasonable accuracy. 
> In inpolygon (line 97)
  In grain2d/checkInside (line 87)
  In grain2d/checkInside (line 60)
  In grain2d/subsref (line 36)
  In EBSDsquare/fill (line 42)
  In EBSD/smooth (line 36)
  In GND_90_long (line 118) 
Warning: The results from INPOLYGON may not be reliable. The size of the
polygon is approaching the upper limit of what can be handled with
reasonable accuracy. 
> In inpolygon (line 97)
  In grain2d/checkInside (line 87)
  In grain2d/checkInside (line 62)
  In grain2d/subsref (line 36)
  In EBSDsquare/fill (line 42)
  In EBSD/smooth (line 36)
  In GND_90_long (line 118) 
Warning: The results from INPOLYGON may not be reliable. The size of the
polygon is approaching the upper limit of what can be handled with
reasonable accuracy. 
> In inpolygon (line 97)
  In grain2d/checkInside (line 87)
  In grain2d/checkInside (line 62)
  In grain2d/subsref (line 36)
  In EBSDsquare/fill (line 42)
  In EBSD/smooth (line 36)
  In GND_90_long (line 118) 
Warning: The results from INPOLYGON may not be reliable. The size of the
polygon is approaching the upper limit of what can be handled with
reasonable accuracy. 
> In inpolygon (line 97)
  In grain2d/checkInside (line 87)
  In grain2d/checkInside (line 62)
  In grain2d/subsref (line 36)
  In EBSDsquare/fill (line 42)
  In EBSD/smooth (line 36)
  In GND_90_long (line 118) 


ruediger Kilian

unread,
Oct 26, 2018, 9:46:07 AM10/26/18
to mtex...@googlegroups.com
You (or mtex) may have created a strange point having coordinates with a pretty big number (>10^150). Check the x,y coordinates of the ebsd variable (ebsd.x ebsd.y) or maybe the grain vertices (grains.V) and try to get rid of it.

Cheers,
Rüdiger

MTEXNewbie

unread,
Oct 26, 2018, 10:24:40 AM10/26/18
to MTEX
Could not figure out using (ebsd.x ebsd.y), but grains.V(:,1) showed Inf once. How can I remove that?

ruediger Kilian

unread,
Oct 26, 2018, 10:42:25 AM10/26/18
to mtex...@googlegroups.com
That could be a quick check and fix maybe:

V = grains.V;
p = grains.poly;
goodgrains = ones(length(grains),1);
for i = 1:length(grains)
hasINF= isinf(V(p{i},:));
if any(hasINF(:))
goodgrains(i) = 0;
end
end
grains = grains(logical(goodgrains))
ebsd = ebsd(grains)



Cheers,
Rüdiger

MTEXNewbie

unread,
Oct 26, 2018, 11:26:25 AM10/26/18
to MTEX
It worked flawlessly, thank you!

I was wondering if this small piece of code should be included in the MTEX code by default? Attracting Ralf's attention on this matter.

mam...@cornell.edu

unread,
Nov 4, 2018, 8:34:21 PM11/4/18
to MTEX
This worked perfectly, thanks!

MTEXNewbie

unread,
Apr 9, 2019, 9:41:18 AM4/9/19
to MTEX
Hi Rüdiger,

The above method removed the map (resin) boundary from the plot but it is present in the grains variable so it will affect the grain size calculation or further calculation.

If I do grains = grains('indexed') right after cleaning operation, then problem happens in Twinning calculation as grainId is required there and it still contains the map boundary. Is there a way to remove the map (resin) boundary permanently at the beginning.

Rüdiger Kilian

unread,
Apr 9, 2019, 6:48:30 PM4/9/19
to mtex...@googlegroups.com
Hi,
yes if I understnad you correctly, probably you should not use ebsd('indexed').calcGrains in that case and properly assign the non-existent areas the 'notIndexed' phase.
Have a look her for a demo how differnet segmentations work, how non-existent and 'notIndexed' pixels work: https://gist.github.com/kilir/d15181bbf9410700fd1b858080dd6bcc
Cheers,
Rüdiger
________________________________________
From: mtex...@googlegroups.com <mtex...@googlegroups.com> on behalf of MTEXNewbie <rashed...@gmail.com>
Sent: Tuesday, April 9, 2019 3:41:18 PM
To: MTEX
Subject: Re: {MTEX} Re: Help with grain boundaries and smoothing

Hi Rüdiger,

The above method removed the map (resin) boundary from the plot but it is present in the grains variable so it will affect the grain size calculation or further calculation.

If I do grains = grains('indexed') right after cleaning operation, then problem happens in Twinning calculation as grainId is required there and it still contains the map boundary. Is there a way to remove the map (resin) boundary permanently at the beginning.

--
If you want to reduce the number of emails you get through this forum login to https://groups.google.com/forum/?fromgroups=#!forum/mtexmail, click "My membership" and select "Don't send me email updates". You can still get emails on selected topics by staring them.
---
You received this message because you are subscribed to the Google Groups "MTEX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mtexmail+u...@googlegroups.com<mailto:mtexmail+u...@googlegroups.com>.
Visit this group at https://groups.google.com/group/mtexmail.
For more options, visit https://groups.google.com/d/optout.

MTEXNewbie

unread,
Apr 11, 2019, 10:45:33 AM4/11/19
to MTEX
Thank you for the demo.

When I do ebsd = ebsd(grains) in the below code, does the initially segmented grains (first line) becomes orientation data again? Just wondering if I choose a seg_angle < 10 deg (default) in the third line, will I miss all the boundaries below that angle?

[grains,ebsd.grainId] = calcGrains(ebsd('indexed'),'unitcell');
ebsd
= ebsd(grains);
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd,'angle',seg_angle*degree,'boundary','tight');


Ralf Hielscher

unread,
Apr 11, 2019, 1:39:07 PM4/11/19
to mtex...@googlegroups.com
ebsd(grains(1))

is a shortcut to

ebsd(ebsd.grainId==1)

Ralf.






********************************************************************
Ralf Hielscher                   Tel: +371-531-38556
Fakultät für Mathematik               +371-531-22200 (Sekr.)
Technische Universität Chemnitz  Fax: +371-531-22109
Reichenhainer Str. 39            E-mail: ralf.hi...@mathematik.tu-chemnitz.de
D-09126 Chemnitz                 http://www.tu-chemnitz.de/~rahi
********************************************************************


--
If you want to reduce the number of emails you get through this forum login to https://groups.google.com/forum/?fromgroups=#!forum/mtexmail, click "My membership" and select "Don't send me email updates". You can still get emails on selected topics by staring them.
---
You received this message because you are subscribed to the Google Groups "MTEX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mtexmail+u...@googlegroups.com.

MTEXNewbie

unread,
Apr 12, 2019, 1:25:53 AM4/12/19
to MTEX
Hi Ralf,

Thanks for chiming in, my question was if I can convert segmented grains to orientation data so that I can segment again using a lower angle.

[grains,ebsd.grainId] = calcGrains(ebsd('indexed'),'unitcell');
ebsd = ebsd(grains);
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd,'angle',seg_angle*degree,'boundary','tight');

Say, I have segmented using the default 10 degree angle in the first line, does ebsd = ebsd(grains) converts grains to orientation data?

Ralf Hielscher

unread,
Apr 12, 2019, 1:32:28 AM4/12/19
to mtex...@googlegroups.com
There is no need to convert grains into orientations. The orientations are already there. And yes

ebsd(grains) 

select those orientations that belong to the grains. And you can segment them again.

Ralf.


********************************************************************
Ralf Hielscher                   Tel: +371-531-38556
Fakultät für Mathematik               +371-531-22200 (Sekr.)
Technische Universität Chemnitz  Fax: +371-531-22109
Reichenhainer Str. 39            E-mail: ralf.hi...@mathematik.tu-chemnitz.de
D-09126 Chemnitz                 http://www.tu-chemnitz.de/~rahi
********************************************************************

--

MTEXNewbie

unread,
Apr 12, 2019, 1:46:21 AM4/12/19
to MTEX
Hi Ralf,

Thanks for confirming. I should have better worded that question, ebsd(grains) removes previous segmentation (boundaries).

Rüdiger Kilian

unread,
Apr 12, 2019, 1:48:56 AM4/12/19
to mtex...@googlegroups.com
Hi,
ebsd_subset=ebsd(grains_subset) does nothing to grains, or grain boundaries.
Cheers,
Rüdiger
________________________________________
From: mtex...@googlegroups.com <mtex...@googlegroups.com> on behalf of MTEXNewbie <rashed...@gmail.com>
Sent: Friday, April 12, 2019 7:46:21 AM
To: MTEX
Subject: Re: {MTEX} Re: Help with grain boundaries and smoothing

Hi Ralf,

Thanks for confirming. I should have better worded that question, ebsd(grains) removes previous segmentation (boundaries).

--
If you want to reduce the number of emails you get through this forum login to https://groups.google.com/forum/?fromgroups=#!forum/mtexmail, click "My membership" and select "Don't send me email updates". You can still get emails on selected topics by staring them.
---
You received this message because you are subscribed to the Google Groups "MTEX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mtexmail+u...@googlegroups.com<mailto:mtexmail+u...@googlegroups.com>.

MTEXNewbie

unread,
Apr 12, 2019, 3:04:46 AM4/12/19
to MTEX
Hi Rüdiger,

But ebsd_subset=ebsd(grains_subset) does remove boundaries form grains_subset and makes it ready for further segmentation at a lower angle than initial segmentation?

Rüdiger Kilian

unread,
Apr 12, 2019, 5:06:02 AM4/12/19
to mtex...@googlegroups.com
ebsd_subset=ebsd(grains_subset) does nothing to grains_subset
Cheers,
Rüdiger
________________________________________
From: mtex...@googlegroups.com <mtex...@googlegroups.com> on behalf of MTEXNewbie <rashed...@gmail.com>
Sent: Friday, April 12, 2019 9:04:46 AM
To: MTEX
Subject: Re: {MTEX} Re: Help with grain boundaries and smoothing

Hi Rüdiger,

But ebsd_subset=ebsd(grains_subset) does remove boundaries form grains_subset and makes it ready for further segmentation at a lower angle than initial segmentation?

MTEXNewbie

unread,
Apr 14, 2019, 10:28:58 AM4/14/19
to MTEX
Hi Rüdiger,

But the newly assigned ebsd_subset does not have boundaries and ready for further segmentation at a lower angle than initial segmentation?

Rüdiger Kilian

unread,
Apr 14, 2019, 11:45:46 AM4/14/19
to mtex...@googlegroups.com
Hi,
I'm not entirely sure if I understand you, however, an ebsd object never has (grain)boundaries, that's grains. ebsd might have a grainId if assigned during computation of grains. You can segment any ebsd oject with whatever angle you like.
Cheers,
Rüdiger
________________________________________
From: mtex...@googlegroups.com <mtex...@googlegroups.com> on behalf of MTEXNewbie <rashed...@gmail.com>
Sent: Sunday, April 14, 2019 4:28:58 PM
To: MTEX
Subject: Re: {MTEX} Re: Help with grain boundaries and smoothing

Hi Rüdiger,

But the newly assigned ebsd_subset does not have boundaries and ready for further segmentation at a lower angle than initial segmentation?

MTEXNewbie

unread,
Apr 14, 2019, 12:35:42 PM4/14/19
to MTEX
Thanks for confirming, that is the answer I was checking with Ralf.
Reply all
Reply to author
Forward
0 new messages