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?
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 ...
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?
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).
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?
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?
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.
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
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.
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
#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).
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;
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.
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).
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.
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).
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.
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)
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] ....
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);
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?
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.