-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
947 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <math.h> | ||
|
||
float expdev(long *idum) | ||
{ | ||
float ran1(long *idum); | ||
float dum; | ||
|
||
do | ||
dum = ran1(idum); | ||
while (dum == 0.0); | ||
//printf("%f\t%f\n", dum, -log(dum)); | ||
return -log(dum); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <math.h> | ||
|
||
float gasdev(long *idum) | ||
{ | ||
float ran1(long *idum); | ||
static int iset = 0; | ||
static float gset; | ||
float fac, rsq, v1, v2; | ||
|
||
if (*idum < 0) iset = 0; | ||
if (iset == 0) { | ||
do { | ||
v1 = 2.0*ran1(idum) - 1.0; | ||
v2 = 2.0*ran1(idum) - 1.0; | ||
rsq = v1*v1 + v2*v2; | ||
} while (rsq >= 1.0 || rsq == 0.0); | ||
fac = sqrt(-2.0*log(rsq) / rsq); | ||
gset = v1*fac; | ||
iset = 1; | ||
return v2*fac; | ||
} | ||
else { | ||
iset = 0; | ||
return gset; | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="ソース ファイル"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="ヘッダー ファイル"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="リソース ファイル"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="main.cpp"> | ||
<Filter>ソース ファイル</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="random.h"> | ||
<Filter>ヘッダー ファイル</Filter> | ||
</ClInclude> | ||
<ClInclude Include="nrutil.h"> | ||
<Filter>ヘッダー ファイル</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include<iostream> | ||
#include "ItkImageIO.h" | ||
#include "dataIO.h" | ||
#include "random.h" | ||
|
||
#define X_SIZE 170 | ||
#define Y_SIZE 170 | ||
#define Z_SIZE 1 | ||
|
||
#define MIXTURE_RATIO 0.8 | ||
#define MEAN1 7.0 | ||
#define VAR1 5.0 | ||
#define MEAN2 -4.0 | ||
#define VAR2 3.0 | ||
|
||
typedef double feat_t; | ||
typedef unsigned char mask_t; | ||
typedef unsigned char label_t; | ||
|
||
int main(int argc, char **argv) { | ||
|
||
if (argc != 2) { | ||
std::cerr << "Usage:" << std::endl; | ||
std::cerr << argv[0] << " <output directory> " | ||
<< std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
std::string output_dir = std::string(argv[1]) + "/"; | ||
|
||
long idum = -1; | ||
|
||
int xe = X_SIZE; | ||
int ye = Y_SIZE; | ||
int ze = Z_SIZE; | ||
int se = xe*ye*ze; | ||
std::vector<feat_t> img(se, 0); | ||
std::vector<label_t> label_img(se, 0); | ||
|
||
|
||
// class 1 | ||
int x1 = (int)(xe*MIXTURE_RATIO + 0.5); | ||
for (int y = 0; y < ye; y++) { | ||
for (int x = 0; x < x1; x++) { | ||
img.at(xe*y + x) = normal(&idum, sqrt(VAR1)) + MEAN1; | ||
label_img.at(xe*y + x) = 0; | ||
|
||
} | ||
} | ||
|
||
// class 2 | ||
for (int y = 0; y < ye; y++) { | ||
for (int x = x1; x < xe; x++) { | ||
img.at(xe*y + x) = normal(&idum, sqrt(VAR2)) + MEAN2; | ||
label_img.at(xe*y + x) = 1; | ||
} | ||
} | ||
|
||
// Save image | ||
std::string result_dir = output_dir+"org"; | ||
make_dir(result_dir); | ||
save_vector(result_dir + "/debug.mhd", img, xe, ye, ze, 1., 1., 1.); | ||
|
||
result_dir = output_dir + "label"; | ||
make_dir(result_dir); | ||
save_vector(result_dir + "/debug.mhd", label_img, xe, ye, ze, 1., 1., 1.); | ||
|
||
|
||
// For mask | ||
std::vector<mask_t> mask(se, 1); | ||
result_dir = output_dir + "mask"; | ||
make_dir(result_dir); | ||
save_vector(result_dir + "/debug.mhd", mask, xe, ye, ze, 1., 1., 1.); | ||
|
||
return EXIT_SUCCESS; | ||
} |
Oops, something went wrong.