C++ :: 2D Image In Memory - Changing To Grayscale
Aug 12, 2014
I'm trying to change a memory block values that is a 2d image. How to change to change scale but it's not working. This is the code
Vivienne
void Image::GenerateGrayScale(void) {
// create temporary area
unsigned char * tempdata_ = new unsigned char[width_ * height_ * depth_*components_];
unsigned char grey;
[Code] ....
I'm trying to employ this method [URL] .....
View 1 Replies
ADVERTISEMENT
May 14, 2013
I have an assignment on image processing and amongst other question one of them specifies:calculate the equalized histogram of a grayscale image and show statistical data of your choice between the input and output images.
I am having trouble equalizing the histogram. Either I am missing the whole picture or minor details that cause problems.
Code:
// original histogram
for (i=0; i<lines; i++)
for (j=0; j<columns; j++)
hist[image_in[i][j]]++;
//histogram max and min
int hmax=-1,hmin=257;
for(int i=0;i<256;i++) {
[Code]...
I am thinking that my equalization formula is wrong, i might have incorrectly translated the mathematical formula from wikipedia to C code but i cant figure out why.
View 9 Replies
View Related
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
Feb 11, 2014
I now have a file with X, Y, Z and Intensity (0-1) of all the pixels. I want to create a .bmp file (grayscale) with this information in C++. How to do it?
View 1 Replies
View Related
Nov 13, 2014
Problem in converting Jpeg to DIB, Iam using the same code for Jpeg RGB(Jpeg_color_space=JCS_RGB) and Grayscale Images(JCS_GRAYSCALE). this code works correctly for Jpeg RGB Images when i create DIB for 24 bit. But for Jpeg Grayscale(JCS_GRAYSCALE) images, when i am converting to DIB I get a Black color space next to image,but the original image does'nt contain any black space.
Following is the code i use for converting jpeg to DIB.
//Function to convert jpeg to dib.
int convert_jpeg_to_dib(const char * filename) {
struct jpeg_decompress_struct cinfo;
unsigned char * buffer;
int result = 0;
struct my_error_mgr jerr;
FILE * infile; /* source file */
int row_stride; /* physical row width in output buffer */
[Code] .....
View 1 Replies
View Related
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
Dec 17, 2013
If I was to input for example 'x' into my program, how could I change that to something like 'HuS581' every time that specific character was inputted?
View 2 Replies
View Related
Oct 30, 2013
I was talking to someone earlier about how to change the value of something from a function, and they said what was needed was to use a ** to change something, and was wondering if I could get a walk - through of what happens. I understand a single pointer well enough, but a pointer through a pointer is kind of confusing to me. Here is a simple example.
Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
int add(int ** TOP, int * stack);
int *stack = NULL;
[Code] ....
Why is it that when the program prints the address of TOP in main, it is different than the address of TOP in the function? Is it because it is a different instance of TOP because it is in the function? When I put the number on *TOP, and come out of the function back to main, it then says the address of TOP is the number entered into *TOP, and am not sure why. And the **TOP ++ at the end I am thinking it increments malloc by 1, therefore bringing the pointer TOP up to point at the next element, or am I completely off base there?
View 7 Replies
View Related
Nov 7, 2013
#include <iostream>
#include <iomanip>
using namespace std;
// cin.get() <-------------- used to let the user read the screen
// Function prototypes
void calcSales(const int [], const double [], double [], int);
void showOrder(const double [], const int [], int);
[Code] ....
How can i change the "const int NUM_PRODS = 12;" from saying id 1, id 2, id 3, etc. to custom product numbers?
View 1 Replies
View Related
Jan 1, 2015
I use miracle library to work with big numbers. I defined a number for example X with 192 bit. at first X= 0 ;I want to change for example 3 bit of it to 1 randomly.as a example:
assume that X has 10 bit :
X=0000000000
random numbers should be :
1000010001
1010100000
1100000100
View 1 Replies
View Related
May 5, 2012
For the following code :
s = 0 ;
for(i=m ; i<=(2*n-1) ; i+=m) {
if(i<=n+1)
{ s+=(i-1)/2 ; }
else
{ s+=(2*n-i+1)/2 ; }
}
I want to change the complexity of the code from O(n) to O(1) . So I wanted to eliminate the for loop . But as the sum "s" stores values like (i-1)/2 or (2*n-i+1)/2 so eliminating the loop involves tedious calculation of floor value of each (i-1)/2 or (2*n-i+1)/2 . It became very difficult for me to do so as I might have derived the wrong formula in sums of floors . Need Changing complexity from O(n) to O(1). Is there any other way to reduce the complexity ? If yes ... then how ?
View 3 Replies
View Related
May 15, 2012
I have this code which previously used the BigInteger library, however now I have GMP installed and I want to use that instead.
I have read the manual but I cannot figure out how to use GMP in this function without getting errors.
Here is the function:
Code:
int lucas(long p){ //p is a number in the range of 2 up to 50,000,000, possibly bigger
int s = 4; //previously assigned as a big integer
int z; //used in the for loop below
int M = 2; //previously assigned as a big integer
for(z = 1; z < p; z++){ //this accomplishes the same as 2 to the power of p, and is stored in M
M *= 2;
}
M--;
[code]....
I can initialize variables using the gmp library, but when I'm trying to use the mpz_pow_ui() function I get errors because it wants me to use long integers, which are too small for the numbers I want to work with.
How can I re-write this function to use GMP?
View 4 Replies
View Related
Jun 11, 2013
Basically, I have a pointer to a C string:
Code: char **objectData and a C string:
Code: char temp[350]; I need to assign the CONTENTS of the temp to the CONTENTS to which objectData points.
Code: *objectData = temp; //this changes the pointer. When temp is deleted, objectData points to some rubbish
**objectData = *temp; //this doesn't seem to be doing anything - the string to which objectData points does not change.
View 3 Replies
View Related
Aug 22, 2014
I was wondering if there was a possible way to change my c program into an application so that i can send the application to another person and not let the other person have access to my codings?
My reasons for asking this question: For the application i want to send there are secrets that are meant to be unraveled by gameplay but i dont want people to look at the codes and know everything.
View 6 Replies
View Related
Mar 13, 2014
SO lets say I have a file that says
10 tennent
9 Eccleston
12 Capaldi
11 Smith
How do I get the number's in order but not changing the name it goes with? SO here is how I started it
# include <iostream>
# include <fstream>
# include <sstream>
# include <set>
# include <list>
# include <string>
# include <cctype>
# include <vector>
[Code] ....
View 12 Replies
View Related
Jun 15, 2013
If I have an array of two columns that have the same values and I want to change only the third column how can I go about doing this. The values of the third column will change based on the values in one of the columns which I plug into a math equation. Also how come I can't show a double value in the array?
#include <iostream>
#include <math.h>
#include<iomanip>
#include <vector>
using namespace std;
[code]...
View 7 Replies
View Related
Apr 28, 2013
I have a problem with my code which I can't work out:
double Mi = 200*pow(10,30);
cout << "
Enter accreted mass increment in solar masses
";
cin >> dm;
cout << "
[Code] ....
Basically the loop works, but gives the wrong results.
I need, at the end of the loop, to sort of "redefine" Mi as "Mi + Macc". I then need it to repeat the loop, and at the end add another Macc so that Mi becomes "Mi + Macc + Macc", etc.
View 5 Replies
View Related
Jan 21, 2015
I want to change string to bool but I'm having trouble doing this.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int check_Pythag(int DIMA, int DIMB, int DIMC) {
[Code] ....
View 2 Replies
View Related
Sep 18, 2013
I want to change the alpha of a sprite without changing any other colours
View 4 Replies
View Related
Apr 17, 2014
For the past couple days I've been making small improvements on a program I made to keep track of a battle count while playing a game. Mainly to reduce the chore of keeping track yourself while you're playing. But it still becomes a hassle to switch back and forth between the program and your game and I was hoping to be able to set focus to the game after the BattleCount method is called.
Currently I am importing a DLL that somebody recommended I use to make a ActiveProcess method that accepts a integer as a parameter which would set the PID but it doesn't seem to be working. The two methods are as follows.
private void countDownClick(object sender, RoutedEventArgs e) {
//Calls a method within my class that subtracts and adds battle values.
counter.CalculateBattles();
//These two change text on my WPF forms with accessor values from my class.
battlesWonText.Text = counter.BattlesWon.ToString();
battlesLeftText.Text = counter.BattlesLeft.ToString();
[Code] ....
This is the C++ code they told me to use to set focus to another application using a PID.
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 SWP_SHOWWINDOW = 0x0040;
[Code] ....
I'm simply trying to figure out how to set focus to a foreign program using their PID and a button click event in WPF. I'm using Visual Studio 2012 on Windows 7.
View 4 Replies
View Related
Dec 14, 2014
I'm working on a project where we access a tiny premade database in order to log into and access another page. I got the log in part working right, but the last part of the project asks me to lock out the account after a certain number of failed attempts. I'm not sure if I need a method to do this or if I can do it right there in the button handler. I tried creating a method to use on the object that was already there, but I'm not sure if that's the right way to go about it. It says it locks the account, but the value in the database never changes, and I don't know why.
//from the login button handler
protected void btnLogin_Click(object sender, EventArgs e) {
bool IsFound = false;
clsDataLayer dl = new clsDataLayer();
IsFound = dl.GetUser(Server.MapPath("~/AddressBook.mdb"), txtUserID.Text, txtPassword.Text);
if (IsFound) {
Response.Redirect("~/frmUpdateAddress.aspx");
[code]....
View 14 Replies
View Related
Jul 2, 2014
I have a C-Power5200 driver. I want using the C# language change to the controller's IP address.
Here a link to the website and API.C-POWER 5200
In Annex API controller.
View 7 Replies
View Related
Mar 20, 2013
i had created a client server program in MFC using TCP but by doing this the server can only work on one computer because you have to tell the client the ip address to connect to i.e
Code:
ServerAddr.sin_addr.s_addr = inet_addr("10.13.31.112");
so i want to change my code so that i can use broadcasting but i found out that it only works using UDP. I tried changing the code but the error message "error with sendto: 10047" displays when i run the program.
that error means
Address family not supported by protocol family. An address incompatible with the requested protocol was used. All sockets are created with an associated address family (that is, AF_INET for Internet Protocols) and a generic protocol type (that is, SOCK_STREAM). This error is returned if an incorrect protocol is explicitly requested in the socket call, or if an address of the wrong family is used for a socket, for example, in sendto.
here is the code from server:
Code:
WSADATA wsaData;
WSAStartup(MAKEWORD(2,2), &wsaData);
int port = 7171;
if (param)
port = reinterpret_cast<short>(param);
[code]....
View 1 Replies
View Related
Sep 16, 2013
I haven't actually learned how to use arrays yet but I know the basic principle of it and decided to try and implement one to improve my code. I'm sure the thing is a bug ridden mess but I would particularly like to point your attention to the function sortDenomination(). Is what I am trying to do in the loop possible?
The reason why I want to do it this way and not with if statements for each denomination is because I can then easily apply this to the second part of the assignment which sees us split a double into dollars and cents and then process each separately. All I would have to differ for each is change the money_loop variable to include the last two denominations in the array.
Code:
#include <stdio.h>
/*Reads cents input from the user.*/
void getCents(int &read_cents) {
printf("Please enter the amount of cents between 5-95:
[Code] .....
View 10 Replies
View Related
Jan 12, 2015
I have a 10x10 array, initialized to all zeros. I create 2 random numbers for the purpose of guessing a position in the array.
However, when I print the array, the 0,0 spot keeps shifting to match the 2nd random number generated. Is there something strange about the 0,0 spot?
Here is my code:
Code:
seedrnd();
for (x=0;x<2;x++) {
randArray[x]=rnd(10);
}
for (x=0;x<2;x=x+1)
[Code] .....
The 2nd to last print statement actually prints randColumn. The last print statement correctly prints 0.
View 7 Replies
View Related
Feb 4, 2014
I have a GPIO pin(GP4) on a microcontroller with a continuous digital pulse train coming into it. I am writing to it in C and do not have interrupts on this chip. I have been calling my input "#define inputA GP4". In C, I would like to be able to find the positive edge of a pulse and trigger the timer on it. I'm not sure if an XOR will accomplish what I need by storing inputA to another variable at some point. Would it be possible to accomplish this by writing code that acts like a positive-edge triggered flip-flop?
The other problem that I have is I need to be able to do this and not get caught in an infinite loop where I can still do other things sequentially with my code, if for instance, inputA goes to 0 and stays at 0 permanently. This means that my option of using while(inputA=0); is out of the question.
View 2 Replies
View Related