<div dir="ltr"><div><div><div>Hello Fabian,<br><br></div>In your case the limitation is really the fact that you compile your project in 32bits. Using another kind of structure will lead to the same issue as long as it is build in 32bits. So my advice is to compile your project (and ITK) in 64 bits. It will work then (it works on my computer).<br><br></div>Hope this helps,<br></div>François<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 11, 2017 at 5:30 PM, Fabian Torres <span dir="ltr"><<a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">Hi.</span><span style="font-size:12pt;font-family:"Times New Roman",serif"><span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif">Thanks for your responses;
all of them gave me some perspective on the problem.<span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif">Indeed the size of my
matrix is around 3GB and I do have enough memory space to allocate it.<span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif">So I think the problem
lies in the integer overflow and that my program is compiled in 32-bit mode, so
my win32 cannot allocate that size of matrix.<span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif">So what do you recommend?
use another kind of structure that it is not an itk matrix and compiling this
project in 64bits?<span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:12pt;font-family:Arial,sans-serif">Thank you very much. I
do appreciate the time you took for this subject.<span></span></span></p></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 11, 2017 at 1:08 PM, Lowekamp, Bradley (NIH/NLM/LHC) [C] <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" link="blue" vlink="purple" lang="EN-US">
<div class="m_-8667220397485991787m_-8487906454607124523WordSection1">
<p class="MsoNormal">Yes, unsigned int’s max is ~4GB, so it “could” work. But working with unsigned integers in the 2GB-3GB range is problematic and trick when subtraction and offsets need to be computed. It is a big red flag to me.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Another possibility, is that the program was just compiled in 32-bit mode. I don’t think a win32 application can allocate that much memory.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Brad<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Francois Budin <<a href="mailto:francois.budin@kitware.com" target="_blank">francois.budin@kitware.com</a>><br>
<b>Date: </b>Monday, September 11, 2017 at 1:57 PM<br>
<b>To: </b>"Lowekamp, Bradley (NIH/NLM/LHC) [C]" <<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>><br>
<b>Cc: </b>Fabian Torres <<a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>>, "<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>" <<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>></span></p><div><div class="m_-8667220397485991787h5"><br>
<b>Subject: </b>Re: [ITK-users] Variable Matrix Access Violiotation<u></u><u></u></div></div><p></p>
</div><div><div class="m_-8667220397485991787h5">
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">@Brad: I looked in the source code and the types of the column and row size variables are "unsigned int" which should allow up to 2^32-1 so 4GB, isn't that correct?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Mon, Sep 11, 2017 at 1:47 PM, Lowekamp, Bradley (NIH/NLM/LHC) [C] <<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">
Oh! I think you are experiencing integer overflow with that size of a matrix. The value Francois (correctly) computed 3,200,000,000 is ~3GB which is greater than numeric_traits<int>::max(), which for 32-bit singed integers is 2,147,483,647. The internal implementation
of this class is vnl_matrix, so the integer limitation lies within that library. So you matrix is too big for this library.<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
When I looked at this e-mail earlier I miss computed the size, so I didn’t realized this problem.<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
HTH,<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
Brad<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">
<u></u><u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:1.0in">
<b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Francois Budin <<a href="mailto:francois.budin@kitware.com" target="_blank">francois.budin@kitware.com</a>><br>
<b>Date: </b>Monday, September 11, 2017 at 1:38 PM<br>
<b>To: </b>Fabian Torres <<a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>><br>
<b>Cc: </b>"<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>" <<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>><br>
<b>Subject: </b>Re: [ITK-users] Variable Matrix Access Violiotation</span><u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt;margin-left:1.0in">
Hello Fabian,<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.0in">
You are most likely allocating more memory than what your computer can allocates. If you compute the memory required for your matrix, it will be at least:<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt;margin-left:1.0in">
8 (long doubles on Visual Studio C++ are the same size as doubles) * 2*100*100*2*100*100 = 3 200 000 000 Bytes<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.0in">
This means that you need to have at least that much memory available.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt;margin-left:1.0in">
If your computer does not have this amount of memory available, you will run into errors.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.0in">
Hope this helps,<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.0in">
Francois<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
On Wed, Aug 30, 2017 at 12:24 PM, Fabian Torres <<a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.0in">
Hi evryone. <u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
I´m using itk VariableMatrix to do some image processing. But I have some problems initializing my matrices.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
When I use small sizes like this I do not have any problem<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
//matrix A<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
regionSize[0] = 15;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
regionSze[1] = 15;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
VariableSizeMatrix<long double> matA;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
matA.SetSize(2*regionSize[0]*r<wbr>egionSize[1],2*regionSize[0]*r<wbr>egionSize[1]);<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
matA.Fill(0.0);<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
But when I use bigger sizes like:<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
regionSize[0] = 100;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
regionSze[1] = 100;<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
I get an Acces Violation exception<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
Access violation reading location 0xcdcdcdc1.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
I'm using Visualstudio 2008 and ITK 4.4<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
Does this has something to do with memory allocation?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
Is there a way a could verify if I have enough memory to allocate my matrix?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
Thanks.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="color:#888888"> </span><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.0in">
<span class="m_-8667220397485991787m_-8487906454607124523m-7819910353623902563hoenzb"><span style="color:#888888">-- </span></span><u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="color:#888888">Fabián Torres Robles<br>
Maestría en Ciencias en Ingeniería Electrónica<br>
Ingeniería en Sistemas Electrónicos<br>
Tel. 58081280, 0445534661338<br>
E-mail <a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>,
<a href="mailto:dae.wong@gmail.com" target="_blank">dae.wong@gmail.com</a> </span>
<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt;margin-left:1.0in">
<br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/product<wbr>s/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FA<wbr>Q</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/insight-users</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:1.0in">
<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-8667220397485991787gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Fabián Torres Robles<br>Maestría en Ciencias en Ingeniería Electrónica<br>Ingeniería en Sistemas Electrónicos<br>Tel. 58081280, 0445534661338<br>E-mail <a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>, <a href="mailto:dae.wong@gmail.com" target="_blank">dae.wong@gmail.com</a> <div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%"></div><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%"></div></div></div></div>
</div>
</div></div></blockquote></div><br></div>