Ragazzi ho bisogno di una mano... Ho il seguente codice c
#include <stdio.h>
#include <stdlib.h>
#include "math.h"
//globali
int rows,cols,masksize;
unsigned char **img1,**img2,**img3,**img_o,**img_o2,**img_o3;
double **doublemask;
char **charmask;
char a[64],b[64];
//dichiarazioni funzione
unsigned char** allocabuffer(int r, int c);
void eliminabuffer(unsigned char **buffer,int r);
void readraw(char *filepath,unsigned char **buffer);
void saveraw(char *filepath,unsigned char **buffer);
double MSE(unsigned char **buffer1, unsigned char **buffer2);
double* hist(unsigned char **buffer,char *filepath);
void stretch(unsigned char **buffer);
void threshold(unsigned char **buffer, int th);
void equalize(unsigned char **buffer);
void makechess(unsigned char **buffer);
void makecircles(unsigned char **buffer);
void put_watermark(unsigned char **buffer,unsigned char **watermark);
unsigned char** get_watermark(unsigned char **buffer);
FILE *out;
main()
{
//setup
int i,j,t,frames,frame;
char a[255],c[255],path[1024];
int** intbuffer;
int rowsi,colsi,rowsh,colsh;
rows=512; cols=512;
//rows=480; cols=512;
//rows=400; cols=480;
//rows=1024; cols=1024;
//rows=324; cols=524;
//rows=300; cols=300;
//rows=16; cols=16;
//rows=256; cols=256;
//rows=255; cols=260;
//rows=240; cols=320;
//rows=288; cols=384;
//rows=144; cols=192;
//rows=144; cols=176;
//rows=80; cols=80;
//rows=473; cols=599;
img1=allocabuffer(rows,cols);
img2=allocabuffer(rows,cols);
img3=allocabuffer(rows,cols);
-------------------
//test RGB
rows=240; cols=320;
readrawRGB("D:\\DIEE\\Didattica\\x_images\\misc corso\\Cinescopio_320_240_RGBinter.raw",img1,img2, img3);
saveraw("R.raw",img1);
saveraw("G.raw",img2);
saveraw("B.raw",img3);
img_o=allocabuffer(rows,cols);
RGB2Y(img1,img2,img3,img_o);
saveraw("Y.raw",img_o);
eliminabuffer(img_o,rows); //*/
//cleanbuffs
eliminabuffer(img1,rows);
eliminabuffer(img2,rows);
eliminabuffer(img3,rows);
}
Ho una immagine da elaborare e devo:
Data l’immagine peppers_512x512x24.raw (512x512 pels, 24bpp RGB interlacciati):
1. scrivere una funzione per aprire correttamente l’immagine e salvare separatamente 3
immagini dei canali R, G e B.
2. estrarre la componente Y (luminanza) come definita dalla trasformata adottata dal JPEG e
salvare la relativa immagine.
3. Calcolare l’istogramma a colori (canali R, G, B) e della componente Y e plottarli su un
unico grafico.
Come posso fare per risolvere questo esercizio?
stavo pensando di copiare i canali su 3 buffer distinti uno r uno g e uno b con la stessa risoluzione dell immagine con 8 bit per pixel, poi costruire un nuovo buffer per costruire la componente y attraverso la trasformazione spaziale (tramite la matrice)... e poi applicare la funzione istogramma ai 4 buffer creati... è corretto? qualcuno saprebbe darmi una mano sul codice da creare? non son molto pratico...