C :: Verified Code For Computing Fast Furrier Transform Of Image

Jun 9, 2013

i am looking for a verified code in simple c, for generating fft of an input image (.jpg). the output can be a text file including fft coefficients.can you recommend me any source except open-cv?

View 6 Replies


ADVERTISEMENT

C++ :: Transform Integer Array To BMP Image

Jun 8, 2013

I have a problem concerning transforming int array into bmp image. I wanted to add a post in this topic: [URL] .... , but unfortunately it is closed. Actually I have a question concerning the code written by Duoas. I have a function which takes values from the file and I want to convert it into bmp with the use of Duoas code. I do it like that(it's Duoas code + my load and main function) Is it something wrong with how I do it or it's rather sth wrong with the file.

It compiles without errors but when I run it: core dumped.

According to gdb debugger problem is here: double hue = (intarray[ row - 1 ][ col ] - min_value) * granularity; programs stops, segmentation fault ...

#ifndef INTARRAY2BMP_HPP
#define INTARRAY2BMP_HPP
#include <fstream>
#include <iostream>
#include <string>

[Code] ....

View 2 Replies View Related

C++ :: JPEGs Recovery From Forensic Image - Optimizing Code

Jan 21, 2013

I'm taking a CS course and we've been tasked with creating a program that recovers jpegs from a formatted CF card which uses the FAT file system with a block size of 512 bytes, the jpegs in the card are block aligned which means that the beginning of a jpeg marks the end of the former.

I've wrote the program and it works nicely and recovers the 51 jpegs in the CF card (actually just an image of some 4-5 megabytes of the actual card which can be downloaded here) but I'm looking for ways to optimize/improve my code so I need a second look from experienced programmers.

Here's my code:

Code:
/*
* filename : recover.c
* description : Recovers jpegs from a forensic image
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define BLOCK 512 // fat file system block size
int main(void) {
// open CF card image

[Code] .....

My questions are:
1) What are the possible optimizations that can make my code faster/better/more concise?
2) I'm not handling slack space, since trailing zeros at the end of a jpeg won't affect rendering it (we were told it won't contain any garbage values)... how may I approach the problem?
3) Can I enhance my if else constructs? or even replace them with something more elegant?

View 14 Replies View Related

C++ :: SDL Object Moves Too Fast

Jan 2, 2013

I am currently making pong using visual C++ with the SDL libary. I find that the ball moves too fast for the players and needs to slow down. The code for the movement is in a while loop and vairies speeds 1 - 2 (X and Y).

CODE:

//ball movement{
ballX += speedX;
ballY += speedY;
//}

ballX and ballY is the position of the ball.
speedX and speedY are the speeds. these change from 1 - 2

How to make the ball move less than one pixel or something along those lines.

View 8 Replies View Related

C++ :: Generate Random Data (fast)

Feb 20, 2013

I just want to know how fast can C++ generate data? For example, I have a downstream device that is connected to my pc via a Gigabit Ethernet, and I have to generate some pattern and send it over the Gigabit interface.

I was curious if there is a way that I can see how fast I can generate data? I was curious if I can exercise a good portion of the bandwidth ! for example, sending about 600 Mbits/sec.

How do I find out, first, whether I can do this with C/C++, and, second, how do I know how fast I am sending data?

View 4 Replies View Related

C++ :: Huge Vector - Find Item Fast

Dec 31, 2012

I want to build a server which holds hundreds of thousands of active users in memory. To keep all the users organized i would like to store them in a Vector.

The problem is how i could quickly and easy find the object whenever i need it? All users will have a unique ID. Would it be possible to keep some form of a Vector Index on the unique id number?

View 2 Replies View Related

C++ :: Column Based Database - Constructing Very Fast Radix Sort

Apr 12, 2014

I'm attempting to build a column based database, and I'm new to C++ (just wanted to play around with building a column base database "for the fun of it"). I want to construct a very fast radix sort, that would allow me to quickly sort groups of columns based on integer values. My general preference is to take up more RAM to get more performance.

I'd like to build the radix sort by allowing 256 "buckets" to drop values in as I'm sorting. This allows me to sort through a group of 4 byte integers in only 4 passes. But assuming I'm trying to sort a large group of values (say 50+ million), I'm not sure what type of container to use for these. Also note I'm pretty unfamiliar with the "standard library", so below are my thoughts:

Vectors:
-Pros: Easy to use, and very fast for sequential and random access inserts / reads
-Cons: If they have to dynamically resize because a given vector wasn't large enough, this can apparently really slow performance. Unless I make another pass over the numbers before I start sorting, I wouldn't know how big to make individual the individual vectors. This means I either have to make them "too big" and waste space, or pay a performance price for either resizing, or scanning data first.

Lists:
-Pros: Seems like I wouldn't have to specify size ahead of time, so I could just easily insert values to a given list. Also, since I don't need random access reads (I'll ready the "0" list sequentially, then the "1" list, etc. they should work fine.
-Cons: I don't really know much about lists, but I'm not sure how easy it is to append a new value to the end of a list. I've read that standard library lists include both "forward" and "backward" pointers, which I don't need. Also, I find it hard to believe that there isn't some time taken up with memory allocation. If I build a list and append x million records in it, is it calling memory allocation routines x million times?

Or maybe there's another container type I should learn?

Again, my goal is to make this "fast", not "memory efficient". But having said that, the fastest way I could think of (use 256 vectors, each sized equal to the total number of members to be sorted) is just too much memory to burn - 256 times a vector big enough to hold millions of elements is too much.

View 4 Replies View Related

C++ :: Why Windows Multi-threading Data Fetch IOPS Too Fast

Feb 10, 2012

I have a SSD and I am trying to use it to simulate my program I/O performance, however, IOPS calculated from my program is much much faster than IOMeter.

My SSD is PLEXTOR PX-128M3S, by IOMeter, its max 512B random read IOPS is around 94k (queue depth is 32). However my program (32 windows threads) can reach around 500k 512B IOPS, around 5 times of IOMeter!!! I did data validation but didn't find any error in data fetching. It's because my data fetching in order?

I paste my code belwo (it mainly fetch 512B from file and release it; I did use 4bytes (an int) to validate program logic and didn't find problem).

#include <stdio.h>
#include <Windows.h>
/*
** Purpose: Verify file random read IOPS in comparison with IOMeter
**/

//Global variables
long completeIOs = 0;
long completeBytes = 0;
int threadCount = 32;
unsigned long long length = 1073741824; //4G test file

[Code] ....

View 1 Replies View Related

C++ :: Computing Net Pay - Too Few Arguments

Apr 13, 2013

double compute_taxes(double gpay) {
double gross;
double td; // to hold the tax deduction
if (gross <= 1000)
td = gross * 0.5;
else if(gross < 1500)
td= gross * 0.6;

[Code] ....

Write the function double compute_npay(double gpay) that receives an employee's gross pay using the value parameter gpay, computes the net pay and returns it. the net pay is the gross pay - the tax deduction. To compute the net pay, it first calls compute_taxes() to compute the tax deduction.

View 4 Replies View Related

C :: Computing Ratio With Array?

Feb 10, 2014

What is wrong with this code cause im not getting the correct ratio of total people to cumulative length?

Code:
#include<stdio.h>
#include<stdlib.h>
//define constant variables
#define FIRST_CAR_LENGTH 10
#define NORMAL_CAR_LENGTH 8
#define CAR_CAPACITY 4
int main(void){
//Set up some variable with values that come from input or calculations

[Code].....

View 7 Replies View Related

C/C++ :: Computing Bit Difference Between Two Arrays?

Jul 23, 2014

#include <stdio.h>
#include <stdlib.h>
int b_diff (int, int);

[Code].....

I am trying to take two arrays H[], and V[] and call each element to compute the bit difference(Hamming distance) and return that back to the main function to be used in calculating pixel_phase and pixel_smoothing. I'm getting an error that bit_diff cannot be used as a function and I've tried renaming it but nothing seems to work.

[ int b_diff (int a, int ] is how it should actually look.int b_diff (int a, int is how it should actually look).

View 14 Replies View Related

C++ :: Transform XML To TXT

Apr 14, 2015

This is how my .xml page looks in a web browser. Is there a way to transform my .xml file into .txt file so that the text file would look like this?

View 14 Replies View Related

C :: Program Is Not Computing Averages From Array

Sep 23, 2013

This code is not computing the averages.. I am trying to add up all the values in the array and divide them by the number of addresses in the array

Here is the snippet of what I have do far :

//Run through all possible train combinations

Code] :

for(tl=10; tl<=max_tl; tl+=8) {
n_cars++;
num_trains=(.25*max_track)/tl;
num_people=n_cars*num_trains*4;

[Code] ....

View 10 Replies View Related

C++ :: Computing The Riemann Zeta Function?

Sep 30, 2013

I'm suppose to provide an inner loop that computes the zeta function and the other loop is just press y for to continue, anything else exit.so far i got this:

#include <iostream>
#include <cmath>
#include <stdlib.h>
using namespace std;
int main() {
double x, n,zeta;

[code]....

I can't seem to get the formula right.

View 2 Replies View Related

C# :: Transform Seconds Into HH:MM:SS?

Jun 18, 2014

I am trying to transform seconds into HH:MM:SS. I thought it would be easy using the TimeSpan functions however my hours exceed 24 hours now and then therefor it is not viable for use.

private string getFormattedTimeFromSecond(double second)
{
TimeSpan t = TimeSpan.FromSeconds( second );
string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s",
t.Hours,
t.Minutes,
t.Seconds);
}

This is what I have tried, however it does not like it much when hours exceed 24.

View 6 Replies View Related

C++ :: Recursive Function For Computing Total Route

May 11, 2014

How to do recursive function for the following?

RecursiveComputeRouteDistance(p1index,p2index,locations,latitudes,longitudes): recursively computes the total distance between all waypoints (route) using computeDistance function to compute the distance between two adjacent points. You need to recursively compute the distance for the base case(s) and the general case(s).

This is my computeDistance function

int computeDistance(double a1,double b1,double a2,double b2) {
const int R=6378136;
const float Pi =3.14159;
float Dist=0;
Dist= ((Pi*R)/180)* acos((cos(a1)* cos(b1)* cos(a2)* cos(b2)) + (cos(a1) *sin(b1)* cos(a2)*sin(b2)) + (sin(a1)*sin(a2)));
return Dist;
}

View 2 Replies View Related

C/C++ :: Right Triangle Program - Computing Lengths Of Sides

May 5, 2014

I made a simple program to compute the lengths of a triangles sides, but when I enter 30 for angle and 10 for hypotenuse I get the opposite side is -9.880316 and the adjacent is 1.542514.

#include <stdio.h>
#include <math.h>
main() {
float angle;
float hypotenuse;
float adjacent;
float opposite;

[Code] ....

View 2 Replies View Related

C++ :: Finding Pi Through Computing Area Of A Quarter Circle?

May 4, 2015

question: Finding pi through computing area of a quarter circle

my code

PHP Code:

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    int sum=0;            
    double PI,h,x;            
 
[Code] .....

View 14 Replies View Related

C++ :: Doing Fourier Transform - Different Frequencies

Jul 5, 2013

I am having problems doing the fourier transform:

[URL] .....

My code is:

esc = 2;
maxi = 0;
fu = 500;
fo = 3000;

for (f=fu;f<=fo;f + esc) {

[Code] ....

Don't worry about the exp and complex numbers because they work correctly. N is the number of samples of the input (2500). Esc is the difference between different frequences. So the samples of the output are (1250).

View 3 Replies View Related

C++ :: How To Transform A String Into A Char

Feb 8, 2015

I have had quite a head spinner on trying to transform a string into a char. I've been trying to do this for the project below.

[URL] ....

std::string str = "string";
const char* chr = str.c_str();
cout << *chr << endl;

Above is the code I have tried using and it stores data under *chr, it however only stores one letter rather than the entire word like for example string.

View 2 Replies View Related

C++ :: Transform TXT File To Char Vector?

Aug 17, 2013

I need to transform a .txt file to a char vector, but how to do it. as much as I could until now been transformed into vector string.

Code:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

[Code].....

View 7 Replies View Related

C# :: Compare The Image Of A Button To Another Image In Visual Studio

Jul 3, 2014

Im trying to compare the image of a button to another image in Visual Studio like so...

//variables
Image active = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\active.png");
Image stunned = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\stunned.png");

[Code]...

btnStatusPlr1.Image SHOULD come back as True.Then I realized it might not be the same as setting the buttons image in the properties (Which is what i did to get the original image (the one being compared to))

I do have a feeling ive done something wrong here (Yes im a noob /> )

Variable active, is the same image as the buttons default (Well should be)

View 1 Replies View Related

C++ :: Photoshop - Change Color Of Anchor Point In Transform Tool?

Aug 4, 2014

I was wondering if its possible to change the color of the anchor point in the transform tool.

Is this possible? Sometimes I'll move it and it takes forever to find it again on a dark image. The actual image of the cross hairs must live in the application contents somewhere? Or its made by script. After a quick search of "transform" I found this file.. Not exactly sure what I'm looking at inside but it appears to be c++ code? [URL] ....

SCREEN GRAB: [URL] ....
FILE: [URL] ....

View 1 Replies View Related

C++ :: Analysis Of Discrete Wavelet Transform - Modifying For Loop To Make It Faster

Aug 25, 2014

I have this code which performs the analysis part of discrete wavelet transform. It works pretty well. However, I wish to reduce the time that it consumes even further. I did use reserve() and it worked upto few msec.

int rows = signal.size();
int cols = signal[0].size();
int cols_lp1 =(int) ceil( (double) cols / 2);
vector<vector<double> > lp_dn1(rows, vector<double>(cols_lp1));
vector<double> temp_row;
temp_row.reserve(512);

[Code] ....

View 5 Replies View Related

C++ :: Unexpected Result Decrementing End Of Range Iterator In Call To Transform Algorithm

Aug 23, 2013

I found this piece code on the following site:

[URL]

I predicted the outcome as being 01230 as I thought the prefix decrement operator on iterator ce would prevent the final element of the list from being transformed.

I was wrong, the correct output is 01234.

So, I removed the decrement prefix and ran the test again, expecting a different result. It wasn't! The result was still 01234.

Only when I decremented ce twice did I get the result I initially expected, 01230.

why the first decrement of ce appears to have no effect?

#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <cstdio>
int main() {
typedef std::list<int> L;

[code]....

View 2 Replies View Related

C :: Computing Grades From Input File And Writing To Output File

Aug 31, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows: John K. 99, 87, 57, 89, 90, 95 Amanda B. Jones 100, 88, 76, 99, 86, 92 etc.. The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the next (2) at 15% each and the final at 30%. Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:
//
// main.c
// Final Exam
//

[Code].....

The problem I'm having now is how to go about passing the grades to the function computeGrade and then compute the average and return that to the function.

View 4 Replies View Related







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