| | |
Visualize grey scale level image
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 1
Reputation:
Solved Threads: 0
Hello to everybody.I am using microsoft visual c++ compilator 7.0 for image processing.I have wrote down a program that opens a 24 bitmap image and loads it on a 800x 600 matrix after making the average of the RGB bytes.This because I would like to visualize it like a grey scale image.Is this possible?I mean after making the average and loading each value on the matrix how can I visualize it as grey level image?I post the code I hope someone can help me
//program to load a 24 color bitmap on a matrix and visualize its content
//program to load a 24 color bitmap on a matrix and visualize its content
C++ Syntax (Toggle Plain Text)
#include <stdio.h> #include <math.h> #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <windows.h> void load_bitmap(char *,int,int,void *); void main(int argc, char *argv[]) { int i=0,j=0,w=0,h=0,t=0; unsigned char *buf = (unsigned char *)malloc(sizeof(unsigned char)*800*600*3); unsigned char buff[800][600]; //this is the matrix where I want to lad the image char *name = "polyhedron10.bmp"; //this is the name of the image I want to load (it is present on .cpp file folder) load_bitmap(name,w,h,buf); //member function to open the bitmap image for(i=0; i<800; i++) for(j=0; j<600; j++){ //double for cycle to load the image buff[i][j]=(*(buf + t) + *(buf + t + 1) + *(buf + t + 2))/3; t=t+3; } for(i=0; i<800; i++) for(j=0; j<600; j++){ //cycle to visualize content printf("%d,%d",i,j); printf(" %d\n ",buff[i][j]); Sleep(5); } } void load_bitmap(char* filename,int width, int height, void* buffer) { FILE* fp; if((fp = fopen(filename, "rb")) == NULL) //check it is a bitmap image { printf("it is not a bitmap”s�B\n"); return; } printf("pointer to fp is %d\n",fp); fread(buffer, sizeof(BYTE), 600*800*3, fp); fclose(fp); }
Last edited by Ancient Dragon; Sep 14th, 2007 at 12:07 am. Reason: add code tags and remove color tags
![]() |
Similar Threads
- Image read and write operations in turbo C (C)
- audio level detection (Visual Basic 4 / 5 / 6)
- Computer Program Issues (C++)
- So Many Video Cards (Monitors, Displays and Video Cards)
- Backp/Restore HardDisk Image (C++)
- edit text on a gif image in photoshop (Graphics and Multimedia)
Other Threads in the C++ Forum
- Previous Thread: bank system problem !!!! (C++ programming)
- Next Thread: Socket issue + LAN
Views: 1733 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





