//Sector 类型 public static SFRValue Sector_Info2Value(SFRInfo info) { if (info == null || info.block == null || info.block.Length == 0) { return(null); } int nCnt = 0; SFRValue result = new SFRValue(); result.block = new BlockValue[info.block.Length]; for (int i = 0; i < info.block.Length; i++) { result.block[i] = new BlockValue(); } result.dZ = info.dZ; for (int i = 0; i < info.block.Length; i++) { // result.block[i].aryValue = new double[info.block[i].aryValue.Length]; result.block[i].aryValue = info.block[i].aryValue; // result.block[i].aryValue[1] = result.block[i].aryValue[2]; // result.block[i].aryValue[3] = result.block[i].aryValue[4]; result.block[i].dValue = info.block[i].dValue; result.block[i].dX = info.block[i].dX; result.block[i].dY = info.block[i].dY; } return(result); }
public bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false) { if (!bLoad) { return(false); } AlgorithmBase tempModuleBase = GetAlgByIndexID(); if (tempModuleBase != null) { bool result = tempModuleBase.GetSFRValue(bmp, ref SFRValue, ref rectInfo, rectangles, ref lightValue, TestLight); if (SFRValue != null) { for (int i = 0; i < SFRValue.block.Length; i++) { if (SFRValue.block[i].dValue > ParamSetMgr.GetInstance().GetDoubleParam("SFR最大值")) { SFRValue.block[i].dValue = -1; } } } return(result); } else { return(false); } }
public override bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false) { SFRInfo info = new SFRInfo(); // Rectangle[] rectangles = new Rectangle[13]; SFR_C_Info sFR_C_Info = new SFR_C_Info(); SFR_C_Info YData = new SFR_C_Info(); double frequency = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dSFR_Parameter"); bool bRet = false; try { if (bmp == null) { return(false); } Bitmap temp = (Bitmap)bmp.Clone(); int nWidth = temp.Width; int nHeight = temp.Height; byte[] byBuffer = ImageChangeHelper.Instance.Rgb2Gray(bmp); unsafe { fixed(byte *byBufferptr = byBuffer) { bRet = ActiveAlignment.CalibrationMode_Collimators(byBufferptr, nWidth, nHeight, ref sFR_C_Info, ref YData); } } temp.Dispose(); //sfr 转换 SFRValue = AlgChangeHelper.Collimator_Info2Value(sFR_C_Info); rectInfo = AlgChangeHelper.Collimator_Info2Rect(sFR_C_Info); } catch { } double[] value = new double[5]; try { value[0] = YData.block[0].dValue; value[1] = YData.block[1].dValue; value[2] = YData.block[2].dValue; value[3] = YData.block[3].dValue; value[4] = YData.block[4].dValue; } catch (Exception ex) { value[0] = -1; value[1] = -1; value[2] = -1; value[3] = -1; value[4] = -1; //return false; } lightValue.blockValue = value; return(bRet); }
public static SFRInfo Chart_Value2Info(SFRValue value) { SFRInfo result = new SFRInfo(); result.dZ = value.dZ; for (int i = 0; i < value.block.Length; i++) { result.block[i].aryValue = value.block[i].aryValue; result.block[i].dValue = value.block[i].dValue; result.block[i].dX = value.block[i].dX; result.block[i].dY = value.block[i].dY; } return(result); }
public static SFRValue[] Chart_Info2Values(SFRInfo[] infos) { SFRValue[] result = new SFRValue[infos.Length]; for (int j = 0; j < infos.Length; j++) { result[j].dZ = infos[j].dZ; for (int i = 0; i < infos[j].block.Length; i++) { result[j].block[i].aryValue = infos[j].block[i].aryValue; result[j].block[i].dValue = infos[j].block[i].dValue; result[j].block[i].dX = infos[j].block[i].dX; result[j].block[i].dY = infos[j].block[i].dY; } } return(result); }
public abstract bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false);
public override bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false) { SFRInfo info = new SFRInfo(); ObjectInfo objectInfo = new ObjectInfo(); // Rectangle[] rectangles = new Rectangle[13]; if (bmp == null) { return(false); } Bitmap temp = (Bitmap)bmp.Clone(); bool bRet = false; int nWidth = temp.Width; int nHeight = temp.Height; byte[] byBuffer = ImageChangeHelper.Instance.Rgb2Gray(bmp); unsafe { fixed(byte *byBufferptr = byBuffer) { bRet = ActiveAlignment.GetSFRValue_Sector(byBufferptr, nWidth, nHeight, ref info, ref objectInfo, rectangles); } } temp.Dispose(); //sfr 转换 if (TestLight) { double[] value = new double[5]; HObject ho_Image = null, ho_GrayImage = null; try { HObject ho_SelectedRegions0 = null; HObject ho_SelectedRegions1 = null; HObject ho_SelectedRegions2 = null; HObject ho_SelectedRegions3 = null; HObject ho_SelectedRegions4 = null; HTuple hv_XField = null, hv_YField = null; HTuple hv_CenterROIR = null, hv_CenterROIC = null, hv_CenterMinArea = null, hv_CenterSFRThreshold = null, hv_CenterClosing = null; HTuple hv_Corner1ROIR = null, hv_Corner1ROIC = null, hv_Corner1MinArea = null, hv_Corner1SFRThreshold = null, hv_Corner1Closing = null; HTuple CenterMean = null, CenterDeviation = null; HTuple Corner1Mean = null, Corner1Deviation = null; HTuple Corner2Mean = null, Corner2Deviation = null; HTuple Corner3Mean = null, Corner3Deviation = null; HTuple Corner4Mean = null, Corner4Deviation = null; hv_CenterROIR = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIW"); hv_CenterROIC = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIH"); hv_CenterMinArea = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心最小面积"); hv_CenterSFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心阈值设置"); hv_CenterClosing = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心膨胀系数"); hv_XField = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1XField"); hv_YField = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1YField"); hv_Corner1ROIR = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIW"); hv_Corner1ROIC = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIH"); hv_Corner1MinArea = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1最小面积"); hv_Corner1SFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1阈值设置"); hv_Corner1Closing = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1膨胀系数"); ImageChangeHelper.Instance.Bitmap2HObject((Bitmap)bmp.Clone(), ref ho_Image); FindCenterRegions(ho_Image, hv_CenterROIR, hv_CenterROIC, 0, 0, hv_CenterMinArea, hv_CenterSFRThreshold, hv_CenterClosing, ref ho_SelectedRegions0); FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions1); FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions2); FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions3); FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions4); HOperatorSet.Intensity(ho_SelectedRegions0, ho_Image, out CenterMean, out CenterDeviation); HOperatorSet.Intensity(ho_SelectedRegions1, ho_Image, out Corner1Mean, out Corner1Deviation); HOperatorSet.Intensity(ho_SelectedRegions2, ho_Image, out Corner2Mean, out Corner2Deviation); HOperatorSet.Intensity(ho_SelectedRegions3, ho_Image, out Corner3Mean, out Corner3Deviation); HOperatorSet.Intensity(ho_SelectedRegions4, ho_Image, out Corner4Mean, out Corner4Deviation); value[0] = CenterMean.D; value[1] = Corner1Mean.D; value[2] = Corner2Mean.D; value[3] = Corner3Mean.D; value[4] = Corner4Mean.D; } catch (Exception ex) { value[0] = -1; value[1] = -1; value[2] = -1; value[3] = -1; value[4] = -1; //return false; } lightValue.blockValue = value; } SFRValue = AlgChangeHelper.Sector_Info2Value(info); rectInfo = AlgChangeHelper.Sector_Info2Value(objectInfo); return(bRet); }
public static SFRValue[] Collimator_Info2Values(SFR_C_Info[] infos) { SFRValue[] result = new SFRValue[infos.Length]; return(result); }
public static SFR_C_Info Collimator_Value2Info(SFRValue value) { SFR_C_Info result = new SFR_C_Info(); return(result); }
//Collimator public static SFRValue Collimator_Info2Value(SFR_C_Info info) { if (info == null || info.block == null || info.block.Length == 0) { return(null); } int nCnt = 0; SFRValue result = new SFRValue(); result.block = new BlockValue[13]; for (int i = 0; i < 13; i++) { result.block[i] = new BlockValue(); } result.dZ = info.dZ; result.block[0].aryValue = new double[5] { info.block[4].dValue, info.block[4].dValue, info.block[4].dValue, info.block[4].dValue, info.block[4].dValue }; result.block[0].dValue = info.block[4].dValue; result.block[0].dX = info.block[4].dX; result.block[0].dY = info.block[4].dY; result.block[1].aryValue = new double[5] { info.block[0].dValue, info.block[0].dValue, info.block[0].dValue, info.block[0].dValue, info.block[0].dValue }; result.block[1].dValue = info.block[0].dValue; result.block[1].dX = info.block[0].dX; result.block[1].dY = info.block[0].dY; result.block[2].aryValue = new double[5] { info.block[2].dValue, info.block[2].dValue, info.block[2].dValue, info.block[2].dValue, info.block[2].dValue }; result.block[2].dValue = info.block[2].dValue; result.block[2].dX = info.block[2].dX; result.block[2].dY = info.block[2].dY; result.block[3].aryValue = new double[5] { info.block[6].dValue, info.block[6].dValue, info.block[6].dValue, info.block[6].dValue, info.block[6].dValue }; result.block[3].dValue = info.block[6].dValue; result.block[3].dX = info.block[6].dX; result.block[3].dY = info.block[6].dY; result.block[4].aryValue = new double[5] { info.block[8].dValue, info.block[8].dValue, info.block[8].dValue, info.block[8].dValue, info.block[8].dValue }; result.block[4].dValue = info.block[8].dValue; result.block[4].dX = info.block[8].dX; result.block[4].dY = info.block[8].dY; result.block[9].aryValue = new double[5] { info.block[1].dValue, info.block[1].dValue, info.block[1].dValue, info.block[1].dValue, info.block[1].dValue }; result.block[9].dValue = info.block[1].dValue; result.block[9].dX = info.block[1].dX; result.block[9].dY = info.block[1].dY; result.block[10].aryValue = new double[5] { info.block[3].dValue, info.block[3].dValue, info.block[3].dValue, info.block[3].dValue, info.block[3].dValue }; result.block[10].dValue = info.block[3].dValue; result.block[10].dX = info.block[3].dX; result.block[10].dY = info.block[3].dY; result.block[11].aryValue = new double[5] { info.block[5].dValue, info.block[5].dValue, info.block[5].dValue, info.block[5].dValue, info.block[5].dValue }; result.block[11].dValue = info.block[5].dValue; result.block[11].dX = info.block[5].dX; result.block[11].dY = info.block[5].dY; result.block[12].aryValue = new double[5] { info.block[7].dValue, info.block[7].dValue, info.block[7].dValue, info.block[7].dValue, info.block[7].dValue }; result.block[12].dValue = info.block[7].dValue; result.block[12].dX = info.block[7].dX; result.block[12].dY = info.block[7].dY; return(result); }