Windows OS update from 32 bit to 64 bit
이전 댓글 표시
chan_vese.cpp(260) : warning C4267: '=' : conversion from 'size_t' to 'int', > possible loss of data
I recently upgraded my computer from 32 bit to 64 bit, I used to run my image processing algorithm developed on MATLAB2007b platform. After upgrade I am prompted with following error message as shown above. I am using a mex file 'chan_vese.cpp' as a part of image processing, I will be grateful if someone can help me to get rid of this error message.
Thanks in advance
답변 (1개)
Kaustubha Govind
2011년 9월 28일
0 개 추천
This is a generic compiler warning that you could ignore if you like. See Common Visual C++ 64-bit Migration Issues. Basically, size_t and int are both 32-bit wide on 32-bit machines. On 64-bit machines, size_t is 64-bit, but int is still 32-bit wide. This is why you now get a warning about the loss in precision.
To fix the warning, you simply have to insert a static_cast<int>(mySizetVariable) around the variable of type size_t.
댓글 수: 2
Yashasvi Purwar
2011년 9월 30일
Walter Roberson
2011년 9월 30일
Does the code use A^B where A and B are both integer data types? Perhaps it has a uint8 from the image raised to an power?
If you have an integer data type raised to a power, you need to consider whether the result is certain to fit within the limits of that integer data type. If you are certain it will fit, then in place of A^B you can code
cast(double(A)^double(B),class(A))
or for simple squaring or cubing you could code A*A or A*A*A instead.
If you cannot be sure that the result will fit within the limits of the data type, then you should probably be using
double(A)^double(B)
and then being careful after that on how you use the result, as you might well have to convert to back to the integer data type later for the code to work properly.
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!