• 1091. Acute Stroke (30)


    One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core.

    Input Specification:

    Each input file contains one test case. For each case, the first line contains 4 positive integers: M, N, L and T, where M and N are the sizes of each slice (i.e. pixels of a slice are in an M by N matrix, and the maximum resolution is 1286 by 128); L (<=60) is the number of slices of a brain; and T is the integer threshold (i.e. if the volume of a connected core is less than T, then that core must not be counted).

    Then L slices are given. Each slice is represented by an M by N matrix of 0's and 1's, where 1 represents a pixel of stroke, and 0 means normal. Since the thickness of a slice is a constant, we only have to count the number of 1's to obtain the volume. However, there might be several separated core regions in a brain, and only those with their volumes no less than T are counted. Two pixels are "connected" and hence belong to the same region if they share a common side, as shown by Figure 1 where all the 6 red pixels are connected to the blue one.


    Figure 1

    Output Specification:

    For each case, output in a line the total volume of the stroke core.

    Sample Input:

    3 4 5 2
    1 1 1 1
    1 1 1 1
    1 1 1 1
    0 0 1 1
    0 0 1 1
    0 0 1 1
    1 0 1 1
    0 1 0 0
    0 0 0 0
    1 0 1 1
    0 0 0 0
    0 0 0 0
    0 0 0 1
    0 0 0 1
    1 0 0 0
    

    Sample Output:

    26

          识别急性脑卒中(急性脑卒中)的一个重要因素是脑卒中核的体积。根据图像分析的结果,在每个MRI切片中识别核心区域,你的工作就是计算中风核心的体积。

         每个输入文件包含一个测试用例。对于每一种情况,第一行包含4个正整数:m、n、l和t,其中m和n是每片的大小(即一片像素在m乘n矩阵中,最大分辨率为1286乘128);l(<=60)是脑片的数目;t是整数阈值(如果:连接核的体积小于t,那么该核就不能被计算)。然后给出l片。每片用0和1的n矩阵表示,其中1表示笔画的像素,0表示正态。由于切片的厚度是常数,我们只需计算1的数目就可以得到体积。然而,一个大脑中可能有几个分离的核心区域,只有那些体积不小于t的区域才会被计数。如果它们有共同的一面,两个像素是“连接”的,因此属于同一个区域,如图1所示,所有6个红色像素都连接到蓝色像素。

     

    #include<cstdio>
    #include<queue>
    using namespace std;
    
    struct Node{
        int x,y,z;
    }node;
    int pixel[1290][130][61];
    bool inq[1290][130][61] = {false};
    
    int n,m,L,T;
    
    int X[6] = {0,0,0,0,1,-1};
    int Y[6] = {0,0,1,-1,0,0};
    int Z[6] = {1,-1,0,0,0,0};
    bool judge(int x, int y, int z){
        if(x >= n || x < 0 || y >= m || y < 0 || z >= L || z < 0)  //x,y,z需要取到n,m,L 从零开始 
          return false;
        if(inq[x][y][z] == true || pixel[x][y][z] == 0) //if return fals if  return true
         return false;
        return true;  
    }
    int BFS(int x,int y,int z){
        int tot = 0;
        node.x = x, node.y = y, node.z = z;
        queue<Node> q;                      //q的类型是Node 
        q.push(node);
        inq[x][y][z] = true;
        while(!q.empty()){
            Node top = q.front();              //top类型是Node 
            q.pop();
            tot++;
            for(int i = 0; i < 6; i++){
                int newX = top.x + X[i];     //top x,y,z加上方向增量 
                int newY = top.y + Y[i];
                int newZ = top.z + Z[i];
            
                if(judge(newX,newY,newZ)){
                    node.x = newX,node.y = newY,node.z = newZ;
                    q.push(node);
                    inq[newX][newY][newZ] = true;   //对新节点new入队 2 
                }
            }
        }
        if(tot >= T) return tot;   //要取到等于 
        else return 0;
    }
    int main(){
        scanf("%d%d%d%d",&n,&m,&L,&T);
        for(int z = 0; z < L; z++){
            for(int x = 0; x < n; x++){
                for(int y = 0; y < m; y++){
                    scanf("%d",&pixel[x][y][z]);
                }
            }
        }
        int ans = 0;
            for(int z = 0; z < L; z++){
            for(int x = 0; x < n; x++){
                for(int y = 0; y < m; y++){
                    if(pixel[x][y][z] == 1 && inq[x][y][z] == false)
                     ans += BFS(x,y,z);
                }
            }
        }
        printf("%d
    ",ans);
        return 0;
    }
  • 相关阅读:
    Apple http live streaming 不支持windows?
    CDN设计:[笔记]Analysis of Enterprise Media Server Workloads
    牛项目 Harvest
    一些校园招聘的题目和分析
    关于pdf转doc (word) 的工具 Solid Converter PDF
    A CAP Solution (Proving Brewer Wrong)
    6"电纸书/电子书 PaperCrop pdf重排使用心得
    CDN设计 层级化的cache_A
    Berkeley DB Hash、Btree、Queue、Recno 选择
    PowerDesigner 学习系列 简单操作
  • 原文地址:https://www.cnblogs.com/wanghao-boke/p/8557015.html
Copyright © 2020-2023  润新知