C++ :: White Pixel Value Different From 255

Mar 12, 2014

I am working on image processing in C + + and opencv, I treat images in grayscale, ie the pixel values ​​it must be between 0 (black) to 255 (white).

Mat img; img = imread (file, -1);
for ( int i = 0; i < img. rows ; i ++) {
for ( int j = 0; j < img. cols ; j ++) {
val_pixel=img.at < double >(i,j);
printf( "%d ",val_pixel);
}
printf( "
");
}

when displaying the pixel value from two loop, I get values ​​to 0 and it is normal for propablement black areas, but for whites I find the value -2147483648. I don't understand why this value is not 255.Is there an explanation for this has value.

View 4 Replies


ADVERTISEMENT

C++ :: Textures White In OpenGL

Nov 17, 2013

I don't know why, but textures in OpenGL are white. One day, I must've change something, and now my textures wont load properly. I tried rewriting my code that loads things multiple times, my textures still are white. Here is my code:

(I switched back to the FF pipeline temporarily, in my other projects I use shaders.)

Sprite.hpp

#include <SDL.h>
#include <SDL_opengl.h>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>

#ifndef _SPRITE_H_
#define _SPRITE_H_

[Code] ....

View 2 Replies View Related

C++ :: How To Take Into Account White Spaces In A String

Apr 21, 2013

as i am doing an encryption program on a playfair cipher. I am now stuck on a problem on decryption.If my string is helloworld (without a space), it will decrypt normally.However , if my string has a space in between it. Let`s say Hello World, it will not decrypt normally.How do i take into account the space that is in between hello & world?

example: hello world

View 4 Replies View Related

C++ :: Stringstream Consecutive White Space

Oct 1, 2013

So I have a text file named test.txt on the root of my c:/drive.

I finally managed to arrays working and reading into them, but when I started looking at the data in the array I noticed that stringstream was not "grabbing" a specified space. LINES 83-88

The text file contains the following (note that there is an intentional space after the first word):

I ' m s o r 0 y 4 D a v e , 5 12 12 12 3 7 f 11 2 i d 5 8 1 c 5 n 10 t 5 7 17 2 3 h 7 2 .

I need that space to be caught in the steam, there will always be only one space after a various first word, but I need it in my array and stringstream doesn't catch it.

if you need to run it, just copy the text to a file named c:/test.txt

When you run the code, you will see after the 3rd iteration it skips the space, is there a way to change this, so I can focus on the decryption algorithm??

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <stdio.h>
#include <sstream>
#include <cctype>
bool is_number(const std::string& s){
std::string::const_iterator it = s.begin();

[Code] ...

View 13 Replies View Related

C++ :: Program That Eliminates White Spaces

May 8, 2013

im trying to write a program for class that when it reads it, it corrects all the spacing and capitalization. so for example, the phrase "the quick bRown fox jumped over the lazy dog" would be converted by the program to "The quick brown fox jumped over the lazy dog"

here is my code:

#include <iostream>
#include <string>
using namespace std;

[Code].....

i click run in xcode, but something goes wrong. the build succeeds but in the output screen it says (11db)

View 3 Replies View Related

C/C++ :: How To Input A String With White Spaces In Between

May 28, 2013

I want to input a string in C with white spaces in between. I have tried %[^/n]*c, and fgets, but both do not work.

View 7 Replies View Related

C# :: Clear White Space On Random Tile Map

Mar 14, 2015

I've got myself a 2d array

int[,] map = new int[100,100];

I've populate that will a bunch of 1's and 0's. The 1 represents a wall, and a 0 is dirt.

I'm looking for a way to clean up my blank spaces outside of my walls. Any algorithm I can use to identify these big areas and replace them with a '1'

for (int y = 1; y < map.GetLength(1) - 1; y++) {
for (int x = 1; x < map.GetLength(0) - 1; x++) {
// Inside here is where I was hoping to archive my work
bool draw = true;
foreach (Room room in rooms)

[Code] ....

Attached is an example of my output.As you will be able to see, there is a lot of brown. I want to fill the brown with walls, but leave space for a path between the rooms.The 'draw' bool is true when I'm outside of a room, just so I don't start throwing walls inside my room.

Example of what the array would look like (for those who don't know)

int[,] map = new int[100,100]
{
{0,1,1,1,1,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,1,1,1,1,0},
};

View 6 Replies View Related

C++ :: Removing All White Space From Line Of Text File?

Jun 30, 2014

this is the code I tried in my code block 10.05.....tried code for removing all white space from a line of a txt file. this is my code it runs but i cant get the result i need.

#include <iostream>
#include <conio.h>
#include <fstream>
#include <string>

[Code].....

View 9 Replies View Related

C++ :: Ifstream Insertion With White Space Delimited Data

Jun 21, 2013

I'm doing a project that takes in a input file with Quarterback statistics. It has their name, team, completions, sacks, touchdowns, etc. It has 16 different variables in all (17 if you count first/last name as two). So I'm trying to read them and I can't figure out how to jump to the new line after it's read the file and put the information in the variables I've created.

#include <iostream>
#include <fstream>
using namespace std;
ifstream din;
void openFile() {

[Code] ....

That's the program I've written. The loop keeps displaying the first line of the file over and over. How can I get it to go to the second line, then the third, then fourth, etc? I need it to display all the lines of the file until it reaches the end of the file.

View 6 Replies View Related

C++ :: Open A File And Counts White Space Separated Words

May 3, 2013

Write a program that opens a file and counts the whitespace-separated words in that file.?

My code that i wrote for this example is as follows...

#include <iostream>
using namespace std;
#include <iostream>
#include <string>
#include <fstream>
int main() {
string filename = "Question 1.cpp"; // File name goes in here

[Code] ....

Is this correct or am i missing something?

View 6 Replies View Related

C++ :: Palindrome - Program Goes Into Infinite Loop Whenever Word With White Spaces Added

Feb 9, 2013

I have an assignment where i have to make a palindrome program. As you can see i have already done the basic palindrome prog, however i am now stuck since the program goes into a infinite loop whenever a word with whitespaces is added.

I have also tried searching for methods online however they do not seem to work for me...

void CPali::check() {
length = strlen(palin);
for (int i = 0, p = length-1; p>i; i++, p--) {
if (palin[i] == ' ')

[Code] ....

View 6 Replies View Related

C++ :: Program That Opens A File And Counts White Space Separated Words

May 17, 2013

Question is : Write a program that opens a file and counts the whitespace-separated words in that file.?

my answer is :

#include <iostream>
using namespace std;
#include <iostream>
#include <string>
#include <fstream>

int main() {
string filename = "Question 1.cpp"; // File name goes in here

[Code] ....

Now I am not sure if im suppose to get a msg saying : The file "Question 1.cpp" has 0 words.

im wondering is the question that im being asked, asking me to input a string of words and then the compiler when it builds and runs the program counts the word spaces.?

View 5 Replies View Related

C++ :: SDL2 - Getting Pixel Value

Nov 5, 2013

I use SDL2. and i was testing some functions i took from some internet and some unwanted results happened.

Code :

Pixel *GetPixel(SDL_Surface *surface, int x, int y) {
Uint8 p8, *buf8;
Uint16 p16, *buf16;
Uint32 p32, *buf32;
switch(surface->format->BitsPerPixel {

[Code] .....

And the output changes time to time.

View 3 Replies View Related

C/C++ :: Get Dimension Of Pixel In Mm?

Apr 17, 2012

I have an image of size 640x480 pixels. It's possible to obtain the dimension in mm of one pixel from that image given only that size?I do not have the size of the image in mm,however.

View 5 Replies View Related

C++ :: Dynamic Memory (array Of Char) - Delete All White Spaces In Text File

Feb 8, 2014

General Purpose: Delete all "white spaces" in text file, until the read-in char is _not_ a whitespace (mark as start of text file).

Problem: Cannot seem to shift char's over properly. (I think my problem is the inner loop - however other code may lead to this problem - I do not know)

Code:

#include <fstream>
#include <iostream>
using namespace std;

bool trimWhiteSpace(fstream &file, char * charMemoryBlock) {
if (!file.is_open()) {

[Code] ....

View 3 Replies View Related

C++ :: How To Find Each Pixel In The Circle

Jul 26, 2014

How can I find each and every pixel in a circle so that I can do some operations on it.

View 6 Replies View Related

C++ :: Getting Pixel Information From Fonts?

Mar 27, 2013

How can I import a font file and get the pixel information of the letters so I can make my own custom text drawing function?

I basically have a pixel surface (a 2D array) and I want to draw the text to that array.

View 1 Replies View Related

C++ :: Rotating Pixel Field

Apr 21, 2014

I wrote a script that generates n random pixel positions and draws them to the screen. Works well. Now i tried to rotate them. Rotating does work too. But it does not work as i planned it.

paramters 'angle' and 'timestep' work somehow, but not as they should do. the function 'move' is supposed to rotate the pixelfield 'angle' degrees in a given direction, addicted to the 'timestep' parameter. 'timestep' is needed time for drawing in one single game loop.

angle_step = timestep * angle
// x
ppdPoint[i]->x =
pRotationPoint->x + cos(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) - sin(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);
// y
ppdPoint[i]->y =
pRotationPoint->y + sin(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) + cos(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);

rotation point is the middle of the screen. when i set angle to 10 it should rotate 10 degrees / second. Instead it's rotating very very fast and all stars are moving nearer to the center of the screen, so after x rounds there is just 1 pixel left in the middle of the screen. there is a kind of gravition.I'm working with SDL2. What I did find out:

FPS is <= 60, 'cause of the 'SDL_RENDERER_PRESENTVSYNC' flag. When i skip that flag, for any reason the 'gravition' would take more time. FPS is <= 1400 then, 'though i got a natural game loop (i hope):

while(pBuild->getExecuteFlag())
{
pBuild->draw();
pBuild->update(time_dif, pTimeWindow->TimeStampB);
time_dif = (pTimeWindow->TimeStampB - pTimeWindow->TimeStampA);
time_dif *= 0.001;
pTimeWindow->TimeStampA = pTimeWindow->TimeStampB;
pTimeWindow->TimeStampB = SDL_GetTicks();

pBuild->count_fps(pTimeWindow->TimeStampB);
}

So maybe (timestep * angle) isn't the right way?

View 13 Replies View Related

C# :: Draw Single Pixel On Window

Mar 27, 2014

Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like a radar PPI screen. Trying to do this in c#, I can't find how to draw a single pixel on the window.

Also, what should I be drawing on: the form, panel, picturebox...?

View 2 Replies View Related

C++ :: How To Convert Pixel To Coordinate In OpenGL

May 23, 2013

How can i convert pixel to [-1..1]coordinate in opengl? Which function? I want to write a program that is work with

glutmousefunc(),

When I click on the screen a ball is appear on it where clicked. but mouse work with pixel and circle work with coordinate between -1 and 1 ....

View 4 Replies View Related

C++ :: Subtracting Pixel Values From Two Different BMP Files

Dec 30, 2014

I would like to subtract one image from another to get something like "differential picture" (i am not sure whether the name is correct). I've managed to read the FILEHEADER and FILEINFOHEADER of bitmap. I will subtract 24-bit bmp files only. However i can't understand the structure of this file. So far my code looks like this. Any example of at least copying one bmp file to a new one? This example would be useful, because subtracting will be simillar, instead of copying the pixel value i will just put abs(value1-value2) in the output.

Code:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
struct BITMAPfileHEADER {

[Code] .....

View 4 Replies View Related

C++ :: SFML 2.0 Pixel Perfect Collision

Oct 15, 2013

I have the code and it compiles fine but it doesn't work. (i am using the coding made easy sfml 2.0 tutorials)

Code:

#include <SFML/Graphics.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
class Player {
public:
sf::Sprite player;

[Code] ....

View 18 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++ :: Finding X / Y Pixel Address In Mode 13h VRAM?

Jul 21, 2013

I'm currently working with linear VRAM (a buffer with 256KB memory, divided into four 64k planes, so plane 0 at 0x00000, plane 1 at 0x10000, plane 2 at 0x20000, plane 3 at 0x30000). Just add the index of the plane to that for the full address in VRAM.

I'm still wondering how to get a specific pixel from VRAM (x,y coordinate) when doing graphic modes (none color modes work, only the black/white pixels (1-bit) graphic mode works).

how I can get specific pixels from the VGA VRAM (having linear access described above) using Shift Register Interleave mode (VGA modes 4&5), 16-bit planar mode (Most VGA modes) etc.

View 4 Replies View Related

C++ :: Accessing Pixel RGB Values In Float Format?

Apr 7, 2013

I have tried everything and i still can't access pixel RGB values in float format.

I tried vec3b which produces strange characters which i can't covert to float as it says no suitable function exists.

I tried vector<float> RGB;

with RGB = image.at<vector<float>>(row,col);

I get a unhandled exception error.

So whatever i do, if it is syntax correct i get unhandled exception error. If it should work i get this stupid error. I need it for chroma keying.

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







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