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
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
Yashasvi Purwar 2011년 9월 30일
Hey Kaustuba,
Apart, from these warnings I am getting some errors too as listed below:
chan_vese.cpp
chan_vese.cpp(73) : error C2668: 'pow' : ambiguous call to overloaded function
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\math.h(583): could be 'long double pow(long double,int)'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\math.h(535): or 'float pow(float,int)'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\math.h(497): or 'double pow(double,int)'
while trying to match the argument list '(int, int)'
chan_vese.cpp(73) : error C2668: 'pow' : ambiguous call to overloaded function
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\math.h(583): could be 'long double pow(long double,int)'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\math.h(535): or 'float pow(float,int)'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\math.h(497): or 'double pow(double,int)'
while trying to match the argument list '(int, int)'
I have no clue, how to get along with these errors. If you can suggest some solution to these errors that will be great.
Thanks in advance
Walter Roberson
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에 대해 자세히 알아보기

질문:

2011년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by