Hi everyone
Please bear with this beginner in C/C++ question....
Problem:
I need to develop simple program for canny edge detector.
Now, I need help to create a routine to read a binary file. The routine must be able to read a binary file and pass these values:
a) first 2 bytes as unsigned integer (assign it to "row" variable)
b)next 2 bytes as unsigned integer (assign it "col" variable)
skip 6 bytes
e) a 2 dimensional array ( data[row][colum] ) from the subsquent bytes left, 1 byte makes up 1 element.
You can use fread or fstream for this routine.
ex: using hexview, the input file is:
02 00 02 00 FF 01 02 01 00 01 11 FF 22 44
then the program
should return
row = 2 (from 00 02-1st 2 bytes)
col = 2 (from (00 02 - 1st 2 bytes)
skip the next 6 bytes (FF 01 02 01 00 01)
data[row][column]= {(17,255)(34,68)} (the rest bytes)
My current program as follow
Code:#include <stdio.h> #include <iostream> void infile(char i){ FILE* input = fopen(i, "rb"); int col, row; double data[600][600]; fclose(input); } int main(){ char i_f; printf("Please enter input image file name"); cin >> i_f; infile (i_f); }
I also have the problem to pass the file input from the main program to the routines with above codes. Seems the parameter for char i mismatch or something.
Could anyone help me to solve this?
Thx for the help.