If statement is been passed over-Simple Opencv project
I cant seem to hit these if statements my code seems to pass over them without altering the values I want. I cant seem to find the problem and the debugger wont hit them either as I run through the code.
Im on windows 7 using visual studio 2010 if that helps.
This is an openCV project to reconstruct an image based on a text file of 1s and 0s.
Code:
// reconstruction1.cpp : Defines the entry point for the console //application.
//
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <math.h>
#include "cv.h"
#include "highgui.h"
#include "stdio.h"
#include <fstream>
using namespace std;
int main ()
{
//create a reconstruction function to take my output files,so far of 1 //and 0s and build an edge map
ifstream myfile;
myfile.open("me.txt");
int height=145,width=138;
//size of myimage
CvSize a=cvSize(200,200);
//create my image for out put
IplImage* img=cvCreateImage(a,IPL_DEPTH_32F,4);
//create pixel
CvScalar pix;
int c,c2;
//makesure its open
if (myfile.is_open())
{
cout<<"ok";
//create loop and count varibles
int c1,b1=0,w=0;
//start loop
while(w<=20010)
{
//this loops through every pixel starting at height width(h,w)
for(b1;b1<=height-1;b1++)
{
for(c1=0;c1<=width-1;c1++)
{
//get next charecter in file, it will be either 1 or 0
c=myfile.get();
c2=c;
//change color of pixel depending on c
// thse are the if statements that arent been checked
if(c2==49)
{
pix.val[0]==255;
pix.val[1]==0;
pix.val[2]==0;
}
if(c2==48)
{
pix.val[0]==0;
pix.val[1]==255;
pix.val[2]==0;
}
//set pixel
cvSet2D(img,b1,c1,pix);
w++;
cout<<w<<"\n";
}
}//close 1st for loop
myfile.close();
cout<<"\n closed";
cvShowImage("go",img);
cvWaitKey(0);
cvReleaseImage(&img );
system("pause");
}
}
return 0;
}