#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
void gray_process(int& blue, int& green, int& red)
{
int gray = (blue+red+green)/3;
blue = gray;
green = gray;
red = gray;
}
int get_int (fstream& stream, int offset)
{
stream.seekg(offset);
int result = 0;
int base =1;
for(int i = 0; i<4; i++)
{
result = result+ stream.get()*base;
base = base*256;
}
return result;
}
int get_pixel(int x, int y , int& pos, int start, int width, int height,fstream& stream)
{
pos=start;
pos+= (((y)*width)*3) + ((x)*3);
}
int main()
{
int gx_matrix[3][3]= {(-1,0,1),(-2,0,2),(-1,0,1)};
int gy_matrix[3][3]= {(1,2,1),(0,0,0),(-1,-2,-1)};
cout<<"Please enter the file name: "<<endl;
string filename;
cin>>filename;
fstream stream;
int blue,red,green;
if(scanline_size%4 != 0)
{
padding=4-scanline_size%4;
}
if(file_size != start +(scanline_size + padding)*height)
{
cout<<"Not a 24-bit true color image file"<<endl;
return 1;
}
int pos = start;
for(int y = 0; y < height ; y++)
{
for(int x = 0; x< width ; x++)
{
int sumx =0; int sumy = 0; int sum = 0; int blue_2; int red_2; int green_2,pix,piy;
if(y == 0|| y == height-1 || x ==0 || x== width-1)
{
stream.seekg(pos);
My purpose is making sobel algorithm using c++. I made above code but it doesnt runnning well. It makes white all pixels. Any help I'll be appreaciated. Thanks.