C++ :: Saving RGB Pixel Data Of JPEG Image In 3D Array

Jan 6, 2015

I need to save RGB values of each pixel in a 3D array A[width][height][3]. I found a code online that transfers the bytes into an array but I cant understand how bytes are saved them so i could transfer them into an array. The truth is I dont know much about working with images at all so i have a problem working on them. How to transfer the RGB data from an .jpeg image into a 3D array? This is my code so far:

#include <iostream>
#include <jerror.h>
#include <jpeglib.h>
using namespace std;
int main(){
FILE *pic = fopen( "image.jpeg", "rb+" );

[Code] .....

View 6 Replies


ADVERTISEMENT

C++ :: Reading JPEG Pixel And Change It After Comparing

Feb 28, 2014

I'm trying to read a jpeg pixel and then compare it if it'x bigger than a number to change it. Either I'm breaking the folder if I start less than 22000 which is very large number shouldn't include the header or I'm getting solid color without any different.

Code:
const char* filename ="Hydrangeas.JPG";
const char* nfilename ="Hydrangeas1.JPG";
FILE *ptr_old, *ptr_new;
errno_t err = 0, err1 = 0;
int a;

[Code] ....

View 5 Replies View Related

Visual C++ :: Displaying JPEG Image

Mar 20, 2014

Which command should i use for displaying a jpeg image in Visual Studio 2008 (VC++)?In the past i used LoadImage function for displaying Bitmaps.

View 14 Replies View Related

C/C++ :: Reading BMP File - Getting Pixel Data Out Into 2D Array

Jan 18, 2015

I have managed to successfully extracted the BMP file header and file info but ran into troubles with getting the pixel data out into a 2d array.This is my function to read the data while i have another to write the data. The output does not match the input at all.

void BMPProgram::GetPixelData(std::ifstream & inStream) {
std::cout << "Entered function";
if(inStream.fail())
return;
//space allocated to reading in of padding
int paddingSpace = 0;

[Code] ....

PIXEL is a struct of 3 unsigned char containing values of RGB.

View 3 Replies View Related

C/C++ :: How To Save Entire Web Page As Image (JPEG Format)

Apr 17, 2014

I was trying to capture entire web screen and save as .jpeg format.

So far I have done this using C# Windows Application.

Same thing I am willing to do in 'VC++ 2010 Win32. In my C++ project I have created a Toolbar with a button on IE 9 browser. And on Toolbar button click I can print current window.

But I don't know how to take a snapshot and save to specified directory in .jpeg format using VC++ 2010. I have Windows 7.

View 4 Replies View Related

C++ :: Grayscale Image - Calculate Slope For Each Pixel

Jan 27, 2015

I have a bw(grayscale) image and want to calculate the slope for each pixel which returns a value 0 to 255 value.

Pixels are always between 0 and 255. The highest possible difference is 255. The end result would be 0 for no slope and 256 for the highest slope.

Would this formula work?

slopex = pixel[x+1,y] - pixel[x - 1,y];
slopey = pixel[x,y+1] - pixel[x,y - 1];
totalslope = sqrt(slopex * slopex + slopey * slopey)*256;

View 3 Replies View Related

C++ :: Saving Array Data Into Text File

Dec 4, 2013

I have a program that saves all information temporarily into memory (into the array), however, I need a permanent save solution. I have the full program working correctly, formatted perfectly, but it's missing the file array to file output.

Essentially, whenever I'm presented with the menu I'll be able to add entries, search by last name, show the entire list, and exit and save. Whenever I select option 4 the program should save to a file "address_book.txt". Whenever I reload the program, it should load from "address_book.txt" and populate the array with the preexisting data.

My question is focused on how and where I should implement the file output. What I have thus far:

#include <iostream>
#include <string.h> //Required to use string compare
#include <fstream> //Eventually used to store array into file
using namespace std;
class AddBook{

[Code] ....

View 5 Replies View Related

C :: Blurring PPM Image By Averaging Components Of Color Within Certain Reach Of Specific Pixel

Mar 13, 2014

I'm trying to blur a ppm image by averaging the components of the color(r, g, b) within a certain reach of a specific pixel. This is a picture and description:

In this diagram, we are trying to compute the color for the pixel in the center (the red element). Its neighbors (within a reach of 4) are all of the green elements. The pixels outside of this 9x9 square are not considered in the blurring calculation for this pixel. To compute the color for the center pixel, average the red, green, and blue components (independently) of every pixel in the 9x9 square (including the pixel itself; the red element in this diagram).

I have some code, but it is not working correctly. The function "computed_color" on line 52 is shown in the next block of code.

Code:
#include <stdlib.h>
#include <stdio.h>
#include "blur_calculations.h"
#define NOT_ENOUGH_ARGS 2
#define MIN_ARGS 3
#define PICTURE_FILE 1
#define REACH_NUMBER 4
#define OUTPUT_FILE "blurred.ppm"
#define PPM_NUMBER "P3"
#define MAX_ROWS 500
#define MAX_COLS 500

void solve(FILE *in_picture, FILE *out_picture, char *argv[]) {

[Code] ....

Here is my code to calculate the average, which I use in my "solve" function:

Code:
#include "blur_calculations.h"
struct color create_color(int r, int g, int b) {
struct color colors;
colors.r = r;
colors.g = g;
colors.b = b;
return colors;

[Code] ....

View 4 Replies View Related

C Sharp :: Saving Picturebox Image With Graphics In It

Aug 23, 2013

What i'm trying to do is load an image from my database create some graphics to it. probably just some lines and marks and save it back to my database. here's so far what I got.
 
for creating graphics:  
 } private void pictureBox3_MouseDown(object sender, MouseEventArgs e) {
            draw = true;
        } private void pictureBox3_MouseMove(object sender, MouseEventArgs e)  {
            if (draw)  {
                Graphics g = Graphics.FromImage(pictureBox3.Image);
 
[Code] ....

but the saving part doesnt work :( I think it only saves the image loaded to the picturebox but not the graphics created to it. how to merge it? i've tried to google it and found some sort of same cases but fails to make it work, something like converting it to bitmap.

View 2 Replies View Related

C/C++ :: Read BMP Image Data Into Multidimensional Array Of Structures

Apr 8, 2014

I am trying to read the information from a .bmp file into my program while dynamically allocating memory for all of it. So I defined the structures for the headers and for a pixel, and then I have to read each pixel into a multi-dimensional array of pixels. I am completely new to structures, and definitely new to pointers combined with structures. I will have to use a filter with the information later, but right now I just want to read everything in correctly. The array of pixels will be two-dimensional -- the width by the height of the image, I guess.

Here's my code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *inFile, *outFile;
typedef struct

[Code] ....

View 4 Replies View Related

C++ :: SDL Library - Access To Pixel Data

Mar 7, 2013

I am using the SDL library, and came across a way to access pixel data.

//A pointer to a surface structure

SDL_Surface *w = SDL_SetVideoMode(800,400,8,SDL_SWSURFACE);

//Casting a void pointer pointing to an array of memory locations(the pixels), to a pointer to an array of Uint8's.
//SDL_MapRGB() Returns an Uint32 containing the color 0,0,255,(0/255, i think it returns the transparency too, or else it would rather return a Uint24,not sure).

Then modifying the memory location, in this case the pixel at the middle of the window.

static_cast<Uint8*>(w->pixels)[(200*w->pitch)+400]=SDL_MapRGB(w->format,0,0,255);

What i seem to not understand is that, i cast pixels to Uint8*, which means I now have a pointer to an array of 8bit numbers, but SDL_MapRGB seemingly returns an Uint32 or Uint24 for a color composed of r,g,b, together without 'a' is 24bits(256=1b,256=1b,256=1b)=3b.

And then i somehow assign that pixel which is of 8bit at chosen location, an Uint24 or 32bit unsigned int.

How does this work?

View 3 Replies View Related

C :: Saving Matrices With Data Structures?

Dec 4, 2014

I'm taking a programming class and currently we're doing data structures. Today, we discussed how to save square matrices column-wise with data structures. The teacher said that after the first few steps where you declare the structure, allocate the matrix, free it and get the dimension (which mostly make sense to me I think), you have to "get" and "set" the matrix by putting in something like

Code:
void setMatrixEntry(Matrix* A, int i, int j, double Aij) {
A->entries[i+j*A->m] = Aij;
}

[Code]....

View 7 Replies View Related

C++ :: Saving Packets Of Data To A Vector?

Jul 18, 2014

I am receiving packets of data from an ethernet cable. This is the line of code that is streaming in data from the ethernet cable:

size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md, 3.0, enable_size_map);[code]

Here are the segments of me trying to push the packets onto a vector:

[code]
std::vector<size_t> processing_queue; //HERE IS WHERE I'M TRYING TO PUSH THE PACKETS ONTO A VECTOR
processing_queue.push_back(num_rx_samps);
[code]

I previously had my program saving to a .dat file (the commented out lines), but I need to change it to pushing values onto a vector so I can stream the data packets from the ethernet cable to be processed. However, the packets aren't being pushed onto the stack as I suspected. What do I need to change to push the data packets onto a vector? The following is the code:

[code]

#include <uhd/types/tune_request.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/exception.hpp>
#include <boost/program_options.hpp>

[code]....

View 1 Replies View Related

C++ :: Saving Unicode Data To TXT File

Sep 13, 2013

I have a problem when i try to save unicode to a .txt file.

I need to store in a file names that will have letters like "ăĂâÂșȘțȚîÎ"

wchar_t name []=L"ăĂâÂșȘțȚîÎ";
FILE* fang;
fang= _wfopen( L"test.txt",L"wt+,ccs=UNICODE");
fwprintf (fang, L"%ls ",name);

When i open my text file i get this: ??âÂ????îÎ

if i use
fang=fopen("test.txt","a");
I get the same result

and for
fang=fopen("ang.txt","a,css=UNICODE");
I get a runtime eroror "invalid file open mode"

View 2 Replies View Related

C# :: Access Database Connection And Saving Data

Mar 17, 2014

I want to connect an access database (.mdb) to my Windows Forms application - this I can do and I have no problems viewing my table in server explorer.

Some code example or template that I can use as a base to learn from - I have literally trawled Google and Youtube and cannot find what I am after.

What I want to do is have a basic form, 2 text boxes and a button to save the data to my database.

FirstName and LastName are the 2 boxes.

View 6 Replies View Related

C++ ::  Saving PNG File In Console Program / Losing Data?

Jul 18, 2013

I am working on a project that uses a web service to extract a PNG image from a web server and save it on a local machine. It's done via a system call. I can get the output of the system call to a FILE but it appears to be losing data, most notably the PNG chunk names (IHDR/PLTE/IDAT/IEND, notably). (Unfortunately piping the output to an exterior file does not work through a system call.) The end result is ~6KB smaller than the file I am intending to retrieve.

This is the code I'm using (adapted from other material I found via searches here):

ofstream png;
png.open(/*outputfile*/, ios::binary);
FILE* fp = _popen(/*SYSTEMCALL*/, "rb");
string responseString;
if(fp != NULL) {
char a[100];
while(!feof(fp)) {
fgets(a, 100, fp);
responseString += a;
}
}
_pclose(fp);
png << responseString;

Am I missing something or just doing it wrong?

View 11 Replies View Related

Visual C++ :: Analyze Bitmap - Concept For Saving Data

May 18, 2014

I would like to create program which will analyse bitmap so would need good concept to save data. I am interested about the theory and I realize that i must to think this carefully because bad concept could create insufficient memory or inefficient program. Basically I want my program work with HSV or HSL model so I would need to convert the bitmap to HSL, but I am not sure if I should convert it first and then analyse all pixels or should I start to analyse the bitmap and make the conversion to HSL during it. But my main question is what method to choose to save the data in memory.

Even that I would start with very small, it should work also with bigger image like image having 1200 or even 4200 px on height. So the program should first analyse all columns of pixels in the image so for example 1200x800 px image has 1200 columns. So I would like to know if is it possible to create such object which would have such structure like this

Obj->basicColumnData->black->columns[name]->group

and in the place of columns should be placed data for every column. I would look for groups of pixels in the column, so in the result the column x could bear e.g. 500 groups of information and every group should contain the range of pixels e.g. group 1 should contain y value from 0 to 20, group 2 should contain value from 25-27 and so on. So I would create 1200 columns bear many of groups. This would be contained in "black" or "white" member to contain the data. This is just simplified idea, but the whole object should contain next data not just basicColumnData... So there should be another members bearing information calculated from the selected data.

So my question is what kind of method of saving data use for this? Should I use heap and dynamic allocated memory or should I create custom class, which will define every member, but these members will have to be dynamic memory? With the dynamic memory is there problem that there could be not enough memory to create such big object?

View 5 Replies View Related

C Sharp :: Saving Data In SQL Server Parameter Error Showing

Jun 1, 2013

I have an application with general customer detail.

It has TextBox and radio button.

First I have used if statement then code but on first step is working fine then error is showing.

try
{
if (textBox1.Text == "")
{

[Code].....

View 5 Replies View Related

C/C++ :: Saving 2D Array To Dat File

Mar 16, 2015

I know how to save/open files but im just confused on where to write the code for it in this block of code :

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int NUM_MONTHS = 12;// Number of months
const int NUM_CATEGORIES = 6;// Number of categories

[Code] .....

View 5 Replies View Related

C++ :: Saving Text Stored In Array To TXT File?

Sep 2, 2013

how to save text stored in an array to a txt file. can sum1 how to save the text in an array to a file/txt file......

View 7 Replies View Related

C++ :: Reading Till End Of File And Saving Into Array

Feb 8, 2013

I am using fin.peek() to read character from input file and saving each character into an array. Each line from the input has first name, last name, id number, and then 5-6 grades. Random spacing between each one.

input file example:
Adam Zeller 45678 80 87 60 90 88 100
David Young 34521 34 56 76 76 76 76
Carl Wilson 909034 90 90 90 49 39

my code for reading in and storing each character is this:

while(fin.peek() == ' ')
fin.get();
while(fin.peek() != ' ') ///// first name {
c = fin.get();
first[i] = c;

[Code] ....

The problem I am having is what sort of loop would go around this to read till end of file. I have tried eof. I have tried while(!fin.peek == ') and I have tried a couple of other methods. these methods resulted in a never ending loop execution.

View 1 Replies View Related

Visual C++ :: Covert Raw Image Data Into PNG

Sep 23, 2013

I have the raw image data and now want to convert it to PNG image. How can i do that? The raw image data is stored in a unsigned char *.

I know how to convert it to Bitmap, but how to convert it to PNG.

View 2 Replies View Related

C++ :: Writing Image Data To Disk In Parallel?

Apr 21, 2012

Basically, I want to write an image to disk in parallel with an algorithm that is processing that same image. The code is really simple:

Code:
string ProcessImage(System::Drawing::Bitmap ^bmp, System::String^ targetFile) {
bmp->Save(targetFile);
System::Drawing::Bitmap^ bmp8 = BitmapConvertPixelFormat(bmp, 8); //<-- a function I wrote which converts the 32bpp I am passed into an 8bpp one
string results = Analyze(bmp8); //<--- takes a good bit of time
return results;
}

What would be the fastest way to do this? Any libraries with a code sample. I would prefer one that is within .NET or native C++ just to avoid having to link into many different libraries.

View 4 Replies View Related

C++ :: Scanning A Header File To Save Image Data

Jun 11, 2013

I'm trying to read from a header file to take the image dimensions and other variables but I don't understand how to iterate through the "key" so it saves each line.

This is what the header file will always look like:

!INTERFILE :=
!imaging modality := nucmed
!version of keys := 3.3
;
!GENERAL DATA :=

[Code].....

Ideally it would just skip the keys that aren't wanted and keep moving through the lines. Should there be a for loop for the key (and if so, how does that work with pointers?) or should this method just be scratched...

View 6 Replies View Related

C Sharp :: How To Access Raw Image Data In Resource File

Nov 14, 2012

I have a .png file that my console app reads and puts into a structure that is saved as a file. The png is always the same so I thought I could just add it as a resource image to a resource file so it would be included in my program and not as a separate file. When I did that, the png shows up as a "SystemDrawingBitmap". If I examine this resource in a watch I see "Base" and "Static" members. Expanding those properties does not give me anything useful such as a pointer to the raw png data and its length in bytes.

If worse comes to worse, I can always make a hex dump of the png contents and then put the hex code into a CS file using static initialization.

Surely there is some way I can access the raw data internally and read the bytes into a byte array using C#

View 2 Replies View Related

C++ :: Design Image Class Which Should Work With Various Data Types (Multidimensional)

Dec 2, 2013

I have been thinking about this all day and I am yet to come up with a good solution. So, I need to design an image class which should work with various data types (int, float, double etc.) and can also be multidimensional (2, 3, 4, 5). So, what I did was generate a template image class as follows:

Code:
template<typename T, int dimensions=3>
class Image {
private:
T * data;
};

Anyway, now I have various image formats that I want to support, so the easy thing to do is create a Factory sort of object which will call eventually generate the correct image.

So I want to create various image classes called ImageType1, ImageType2 etc. which will take the input image and generate the correct Image object. However, I do not want these objects to be templated because they need to be passed from functions and be used in a generic way.

So, at run time I will need to be able to do this…

Code:
class ImageType {
public:
ImageType() {
PolymorphicImage * image = new Image<float, 3>();
}
private:
PolymorphicImage * image;
};

So, I want my ImageType classes to contain the Image object and be able to generate it with the right template arguments at run time. Is there any way to do this without having multiple specialised definitions for ImageType?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved