same same but different???

i tried a bit of code out in a simple form and it worked fine.
then i tried to implement that code into my real project and i used EXACTLY the same structure but i'm not getting any good results and i'm not at all sure why.

and whats the difference between '=' and '=='?
if i change the '=' in the 'implemented code' to a '==' i get different results?

this has been frustrating me all morning :(


simple code...

1
2
3
4
5
6
7
8
9
10
11
12
int cloud [] = {0, 3, 3, 0, 1, 5, 2, 3, 5, 2, 6, 4, 8, 9, 9, 9, 2, 6, 7, 8};
int size = sizeof(cloud) / sizeof(cloud[0]);
vector<float> equalizedRoundHistogram;


for (unsigned int i = 0; i < equalizedHistogram.size(); i++)
   for (unsigned int j = 0; j < size; j++) // size
      if (cloud[j] == i)
         cloud[j] = equalizedHistogram[i];
      else
         cloud[j] = cloud[j];



implemented into 3D point clouds...

1
2
3
4
5
6
7
8
9
10
11
   pcl::PointCloud<pcl::PointXYZI>::Ptr inCld
   std::vector<float> equalizedRoundHistogram;


   for (unsigned int i = 0; i < equalizedRoundHistogram.size(); i++) // equalizedHistogram.size()
      for (unsigned int j = 0; j < inCld->size(); j++) // size
         if (inCld->points[j].intensity == i)
            inCld->points[j].intensity = equalizedRoundHistogram[i];
         else if (inCld->points[j].intensity != i)
            inCld->points[j].intensity = inCld->points[j].intensity;
= is assignment. For example:
 
cloud[j] = i
assigns the value in i to cloud[j]. The value of the statement is i.

== is comparison. For example:
 
cloud[j] == i
compars the value in i to that in cloud[j]. The value is true if they're the same, otherwise false.

Just a comment. In code:
1
2
3
4
5
vector<float> equalizedRoundHistogram;
for (unsigned int i = 0; i < equalizedHistogram.size(); i++)
{
    // loop code
}
the size is zero, so you never enter the loop.
thanks for the = and == explanation.

and equalizedHistogram.size() does have a size, i just didn't include that part of the code as its not important. assume there is a size value anytime size is mentioned :)
Topic archived. No new replies allowed.