dポイントプレゼントキャンペーン実施中!

このサイトで自分がしたいことのサンプルプログラムを見つけたんですけど

http://www40.atwiki.jp/spellbound/pages/1782.html

これはc言語じゃないですよね?

c言語で擬似カラーを表すとどうするんですか???

c言語初心者でサンプルが必要です!

お願いします。

A 回答 (2件)

> double h = 240.0 - ((240.0 / 255.0) * i);


> ここの部分でどのような値が求められているのでしょうか??

質問されたときの参考のサイトにある通りです.
輝度 i を「色相の範囲は赤(0)~青(240)まで」に割り当てています.

> またcaseで場合わけされてる部分でどのような場合わけがわからないのですが

過去に類似の質問があるようです.
これに対するが回答(6通りある~)が参考になるでしょう.

http://oshiete.goo.ne.jp/qa/5905829.html
    • good
    • 0

画像データの扱いを

http://oshiete.goo.ne.jp/qa/7905359.html と同じ要領とすると、
  http://ja.wikipedia.org/wiki/YUV
 http://ja.wikipedia.org/wiki/HSV%E8%89%B2%E7%A9% …
の通りにすると、おそらく下のような感じでしょう。
 
 for (y = 0; y < ysize; y++) {
  for (x = 0; x < xsize; x++){
   double r = image[y][x][0];
   double g = image[y][x][1];
   double b = image[y][x][2];
   double i = 0.299 * r + 0.587 * g + 0.114 * b;

   double h = 240.0 - ((240.0 / 255.0) * i);
   int hi = floor(h / 60);
   double f = h / 60 - hi;
   int q = 255 * (1.0 - f);
   int t = 255 * (1.0 - (1.0 - f));

   outimage[y][x][0] = outimage[y][x][1] = outimage[y][x][2] = 0;

   switch (hi) {
   case 0:
    outimage[y][x][0] = 255; outimage[y][x][1] = t;
    break;
   case 1:
    outimage[y][x][0] = q; outimage[y][x][1] = 255;
    break;
   case 2:
    outimage[y][x][1] = 255; outimage[y][x][2] = t;
    break;
   case 3:
    outimage[y][x][1] = q; outimage[y][x][2] = 255;
    break;
   case 4:
    outimage[y][x][0] = t; outimage[y][x][2] = 255;
    break;
   default:
    outimage[y][x][0] = 255; outimage[y][x][2] = q;
   }
  }
 }
    • good
    • 0
この回答へのお礼

ありがとうございます!!!

double h = 240.0 - ((240.0 / 255.0) * i);

ここの部分でどのような値が求められているのでしょうか??

またcaseで場合わけされてる部分でどのような場合わけがわからないのですが

少し詳しく教えていただきたいのですがよろしいでしょうか??

素人なものですみません。

お礼日時:2013/01/25 01:56

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!