-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoiROIFilter.m
90 lines (60 loc) · 2.22 KB
/
poiROIFilter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// poiROIFilter.m
// poiROI
//
// Plugin with a line ROI that provides statistics regarding the ROI points
//
#import "poiROIFilter.h"
@implementation poiROIFilter
- (void) initPlugin
{
}
- (long) filterImage:(NSString*) menuName
{
NSArray *PixList = [viewerController pixList];
int curSlice = [[viewerController imageView] curImage];
DCMPix *curPix = [PixList objectAtIndex: curSlice];
NSMutableArray *roiSeriesList = [viewerController roiList];
NSMutableArray *roiImageList = [roiSeriesList objectAtIndex: curSlice];
int i,j;
double meansum=0;
double mean=0;
double std=0;
int points;
double min=999999;
double max=0;
for( i = 0; i < [roiImageList count]; i++)
{
if( [[roiImageList objectAtIndex: i] ROImode] == ROI_selected)
{
ROI *Roimus;
Roimus=[roiImageList objectAtIndex:i];
NSMutableArray *pts = [Roimus points];
int xoc[[pts count]];
int yoc[[pts count]];
double values[[pts count]];
for (j = 0; j < [pts count]; j++){
xoc[j]=[Roimus pointAtIndex:j].x;
yoc[j]=[Roimus pointAtIndex:j].y;
values[j]=[curPix getPixelValueX:xoc[j] Y:yoc[j]];
meansum=meansum+values[j];
if(values[j]<min){
min=values[j];
}
if(values[j]>max){
max=values[j];
}
}
mean=meansum/[pts count];
for (j = 0; j < [pts count]; j++){
std+=(values[j]-mean)*(values[j]-mean);
}
points=[pts count];
std=sqrt(std/[pts count]);
}
}
NSString *MyResult = [NSString stringWithFormat:@"Nr. Points:%d \nMin:%.3f \nMax:%.3f \nSum:%.3f \n\nMean:%.3f \nStd:%.3f",points,min,max,meansum,mean, std];
NSRunInformationalAlertPanel(@"poiROI - ROI points info",MyResult,@"OK", 0L, 0L);
return 0;
}
@end