C/C++ :: Color Conversion - Skewed Output

Mar 29, 2014

What the issue is with my algorithm, though it seems to match others that are out there. I believe the output is wrong for what it should be.

Input:

50 50 50
0 0 0
255 255 255
0 100 100
200 200 0
150 0 150
300 0 0
1 1 1
0 0 245

Code:

#include <iostream>
#include <fstream>
using namespace std;
void isValid(int, int, int);
float maximum(float, float, float);
void RGBtoCMYK(float, float, float, float &, float &, float &, float &);

[Code] .....

Output:

0 0 0 0.803922
0 0 0 1
0 0 0 0
1 0 0 0.607843
0 0 1 0.215686
0 1 0 0.411765
0 1 1 -0.176471
0 0 0 0.996078
1 1 0 0.0392157

View 8 Replies


ADVERTISEMENT

C/C++ :: How To Give A Color To The Text That Displayed In Output Screen

Jan 27, 2013

i am using c++v30.5 version i want red color text in in my output screen . i viewed various site but the result is 0 ,wat to do?

View 2 Replies View Related

C++ :: Output String Depending On Color Detected In A Frame Video Feed

Jul 18, 2014

what I'm trying to do is output a certain string depending on the color I see in the video feed. For right now, what I've done is threshold the feed so that everything above a certain brightness shows up as Red. Now I want to have something that says if there's any red in the feed, then I output a "1" to a text box on my user interface that's showing the feed. If there is no red, then I output a "0" to the text box.

I'm using Emgu CV C ++ with VS2010.

This is the code I have so far that isn't working correctly, it's giving me a compiler error.

cvConvertScaleAbs(frameFromCamera->Ptr.ToPointer(),frameDisplay->Ptr.ToPointer(),double(1)/16,0);
cvCvtColor(frameDisplay->Ptr.ToPointer(),frameColorDisplay->Ptr.ToPointer(),CV_GRAY2BGR);
cvThreshold(frameDisplay->Ptr.ToPointer(),maskSaturated->Ptr.ToPointer(),200,255,CV_THRESH_BINARY);

[Code] .....

and the error it's giving me

BAOTFISInterface.cpp(1010): error C2664: 'Emgu::CV::Image<TColor,TDepth> ^Emgu::CV::Image<TColor,TDepth>::InRange(Emgu::CV::Image<TColor,TDepth>
^,Emgu::CV::Image<TColor,TDepth> ^)' : cannot convert parameter 1 from 'Emgu::CV::Structure::Bgr *' to 'Emgu::CV::Image<TColor,TDepth> ^'

[Code] .....

Build FAILED.

View 1 Replies View Related

C# :: WPF Using Color Resource In Rectangle Stroke Color

Sep 7, 2014

Trying to define some global colors so I can use the one instance though-out my application. Here is my color code:

<Color x:Key="GlobalTextColor">#E0E0E0</Color>

But this color doesn't display in the list when I start to type {StaticResource ...}

This is the code where I'm trying to reference the color, see Stroke="{StaticResource GlobalTextColor}". GlobalTextColor doesn't actually come up in the list so won't work.

<Style x:Key="InputButton" TargetType="Button">
<Setter Property="Background" Value="#FF141414" />
<Setter Property="HorizontalAlignment" Value="Left" />

[Code].....

View 2 Replies View Related

C++ :: Sky Color Not Interpolating

Oct 27, 2013

I wrote a sky class for my game, and based on the time, it's supposed to interpolate the color between 5 base colors based on the time.

It starts at noon, however it isn't interpolating at all, just staying at a constant color. Here's the important section of the

code:
#ifndef _SKY_H_
#define _SKY_H_
class CF::Sky {
public:
Sky(GLfloat* sr, GLfloat* m, GLfloat* n, GLfloat* ss, GLfloat* nt, GameTime* g) /*...*/

[Code] ....

View 2 Replies View Related

C++ :: How To Set Color On Inputs And Outputs

Feb 10, 2013

I am new to C++ and I want to learn how to set color a particular color for the users input and output. For example, I want to display the users input as green, and their output as red.

View 2 Replies View Related

C/C++ :: Qt TableView Change Row Color

Feb 24, 2014

I'm creating a simpe program using Qt/C++ and MySQL.

I am trying to change row color of QTableView, but it has to change depending on value on the database.

For example I have QTableview wich is conected to mysql database:

this->model1 = new QSqlQueryModel();
model1->setQuery("SELECT ID, value, Name FROM DB_Table ");
ui->tableView->setModel(model1);

Now I want to change row color to red if the value = 1 .

I searched alot and found this:My link But dont understand how to use these clases in my code, i'm cind a new in programing.

View 3 Replies View Related

C# :: Change Listbox Color?

Dec 22, 2014

I've changed the listbox foreground color to default application background color so I get: [URL] which is fine but when I select any element I get white background/foreground(or whatever it is): [URL]

How can I change this so I will have the same default color in the second case?

It is a windows store app

Xaml code(listbox is at the end):

<Page
x:Name="pageRoot"
x:Class="ExchangeRate2.MainPage"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"

[Code]....

View 1 Replies View Related

C# :: How To Get Color Of Brushes To String

Apr 4, 2015

How can I get the color of Brushes to string?

When I write:

private Brush currentColor = Brushes.White;
label4.Text = currentColor.ToString();

The label shows:

System.Drawing.SolidBrush

View 3 Replies View Related

Visual C++ :: Convert HSB Color To RGB And RGB To HSB?

Jun 11, 2014

I am trying to make this code working and to remake it to work also for RGB to HSB? This code is for C and I need to make it working in Visual Studio C++ .

Code:
// mask1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <math.h>
typedef struct RGB_t { unsigned char red, green, blue; } RGB;
typedef struct HSB_t { float hue, saturation, brightness; } HSB;

[code]....

Error I got is error C3861: 'fmaxf': identifier not found

What file or namespace should I include. Do I need to add some library into linker?

View 14 Replies View Related

C :: How To Generate Random Color Names

Sep 7, 2013

I want to print different color names for "nb " times . I get the number " nb " from the user or from text file . if " nb = 3 " then I want to print any 3 different color names which means that I may print ( red , green , blue ) for example . and if " nb=5 " then I have to print any five different color names ( pink , blue , black , red ,white ) fore example .

Note : " nb " may be a large number ( 17 for example ). How can I do this ?

View 2 Replies View Related

C++ :: Selecting Random Color From Array

Jul 14, 2014

I have to write a program that selects a random color from an array. I used the srand (time(0)); statement but it still gives me the same color each time. Here is my code.

// Color.cpp
#include <ctime>
#include <iostream>
using namespace std;
#include <string>
#include <cstdlib>
#include "Color.h"

[Code] .....

View 7 Replies View Related

C++ :: Change The Color Of Piece In Tetris

Mar 15, 2014

void SetupPieces() {
pieces[0] = Piece(Bads(0,2), Bads(0,1), Bads(0,0), Bads(0,-1));
pieces[1] = Piece(Bads(0,0), Bads(0,1), Bads(1,0), Bads(1,1));
pieces[2] = Piece(Bads(-1,0), Bads(0,0), Bads(1,0), Bads(0,-1));
pieces[3] = Piece(Bads(-1,1), Bads(-1,0), Bads(0,0), Bads(0,-1));
pieces[4] = Piece(Bads(1,1), Bads(1,0), Bads(0,0), Bads(0,-1));
pieces[5] = Piece(Bads(1,1), Bads(1,0), Bads(0,0), Bads(-1,0));
pieces[6] = Piece(Bads(-1,1), Bads(1,0), Bads(0,0), Bads(-1,0));
}

View 7 Replies View Related

C++ :: How To Change Tab Background Color To Green

Aug 8, 2013

Okay, I have a form and I have a tab control thing. On the second tab, I have a button which is supposed to turn the background green.

So, I have this:

#pragma endregion
private: System::Void greenButton_Click(System::Object^ sender, System::EventArgs^ e) {
this ->BackColor = System::Drawing::Color::Green;

But clearly that just turns the FORMS background green. How can I change the TAB background to green.

View 3 Replies View Related

C++ :: How To Change Background Color Of Edit Box

Nov 27, 2013

I am working on this project where I need to update an edit box every couple of seconds with a status and based on the status I need to change the color of the background to a particular color.I am able to update the edit box with the status but is clueless on how to update background color.I have read some info on line about this but is confused.This edit box is on a tab in a dialog. Also, on this tab is a Groupable List Ctrl.

View 2 Replies View Related

C++ :: Color Change Of Text More Than Once In Program?

Jan 13, 2014

How do i change color of text in the program more than once . rite now i use the code

system ("color 0c");//makes the color of the text red
cout <<"hey";
system ("color 02") //change color to green;
cout<<"only in green ";

it displays both the lines in green not the first in red and second in green.

View 1 Replies View Related

C++ :: How To Change Background Color (Mac / Windows)

Jul 19, 2014

I'm creating a simple game with my friend that runs in the Terminal/Command Prompt window, but I would like to know how to change the color of the entire window via C++. I'm on a Mac, but my friend is on a Windows, so I need to a solution that is portable, if possible.

I've tried using a printf statement to change the color, but it only changes the background color of the text being printed.

View 2 Replies View Related

C++ :: Circle Fill Color In - FLTK

Aug 28, 2014

I installed FLTK 1.3.X (from here [URL] ...) on my visual studio 2012 compiler and use PPP book for programming (this: [URL] ..... ). My problem is about filling a Shape in. For example , this code:

#include <Simple_window.h>
using namespace Graph_lib;
int main() {
Simple_window win(Point(100,100), 1000, 600, "Binary_tree");
Graph_lib::Circle c(Point(200,200),50);
c.set_color(Color::red);

[Code] ....

When I run the program, All three Shapes are drawn but only the Rectangle is filled in! Why?

set_color works for the three and apparently the set_fill_color is defined for all Shapes and it too should work but why it doesn't work for Circle and Ellipse?

This is the .CPP and .h files [URL] ....

View 3 Replies View Related

C/C++ :: Change Color Of The Text And Background

Jul 7, 2014

I was trying to change the text and background color to :red blue

Is there a way to do this? is there a certain function? ...

View 1 Replies View Related

C++ :: How To Define New Color That Is Randomly Generated In Allegro

Feb 5, 2014

How do i define a new color that is randomly generated in allegro.

I have this code here in the header file.

Code:

//FILE : circledefs.h
//PURP : Define some constants for circle & background
#ifndef CIRCLEDEFS_H
#define CIRCLEDEFS_H
#define NUMCIRCLES 3
//The frames per second for the timer
#define FPS 60

[Code]...

And what i want to do here is learn how to create a random number gen. Now a few questions if you don't mind telling me is.

1 - can I create 3 random generators in this header file? Or do I have to do this in main.

2 - If I do have to do this in main can I still create this defined RANDOM as a color.

3 - I am sooooo new to this all i know is cin and cout code for C++, so will i need to know more about pointers to do this.

4 - for fun how hard would it be to make a game in allegro that uses music to define how the enemy moves and attacks. (yes that would be the final project.

View 12 Replies View Related

C :: How To Write Header And Color Table From Scratch

Jun 4, 2013

I have been learning about the .bmp format an am able to read in an 8bpp image into an array. Now I want to know how to take an array ex: Matrix[i][j] and print to bmp file. This is what I have so far,

Code:

/////////////// write image to disk
void writeBMP(unsigned char **Matrix, int Matrix_dimension){
FILE *out;
int ii,jj
int filesize = 54 + 4*256 + Matrix_dimension*Matrix_dimension;
}

[code]....

how to write the header and color table form scratch.

View 11 Replies View Related

C++ :: Ways To Change Color Scheme Of Program

Aug 29, 2013

Alright so I'm in a computer programming class and I was given the following problem..Write a problem that takes an integer value and multiplies each of the digits together. 4 digit numbers only.

IE; What number do you want to process? 2684
Starting number 2684
End result 384

I know how to start the begging of the program, but i dont understand how to have it to where you can type in all four digits and then it will multiply each number by the other. Also, what are some ways to change the color scheme of the program? I know how it works using CMD, but in Visual C++ its totally different aha.

View 5 Replies View Related

C++ :: Setting Background Color And Running A Program

Feb 1, 2013

I use turbo c++ 3.0

How to set the background color using the function setbkcolor() in graphics.h

will i need to run the exe file in full screen if i use this function?

View 4 Replies View Related

C++ :: Getpixel Function (SDL Documentation) Color Comparison

Nov 6, 2013

I think that the getpixel function (existed in sdl documentation) gets the color of the coordinate indicated by x and y

Uint32 getpixel(SDL_Surface *surface, int x, int y) {
int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to retrieve */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp) {

[Code]...

my problem is that, I want to compare it with the white/black color ,so how can I do that?

I tried this way but it does not work

int main(int argc,char *argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *screen = SDL_SetVideoMode(600,400,32,SDL_HWSURFACE|SDL_DOUBLEBUF);
SDL_Event event;
bool pass = true;
SDL_Color color = {0,0,0};/// Black color
if(color==getpixel(screen,0,0)

[Code]...

the error C:Documents and SettingsTechno01Bureausdlmain.cpp|83|error: no match for 'operator==' in 'color == getpixel(screen, 0, 0)'|

View 2 Replies View Related

C++ :: PPM Image File Magic Number And Max Color Value

Feb 28, 2015

When reading a PPM Image file, how would I find the magic number and the max color value?

int main() {
string imageFileName;
ifstream image;

imageFileName = "C:UsersDesktopdrink.ppm";
image.open(imageFileName.c_str(), ifstream::binary);

[Code] ....

The code gives me seemingly logical integer values for size, width and height. But how would I find the max color value and so called "magic number" for this PPM image file?

View 1 Replies View Related

C++ :: Two Dimensional Array - Resistor Color Band

Nov 15, 2013

Using functional decomposition, write a C++ program that will prompt user for the all the color bands of a resistor and then calculate the value of the resistor.

The first 3 bands are digits, the 4th is power of 10X and 5th is tolerance.

Here is what the picture look similar to : [URL] ....

if 1st is green (value 5)
2nd is blue (value 6)
3rd is black (value 0)
4th is orange (value 3)
5th is silver (10%)
resistor is 560 x 10^3 with 10% tolerance. or 560 Kilo-ohm with 10% tolerance

a sample program out put:

char BAND_COLOR_CODE[10][8] = {“black”,”brown”,”red”,”orange”,
“yellow”,”green”,”blue”,”violet”,
“grey”,”white”};

[Code] ....

View 1 Replies View Related







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