First blog entry in CSDN :)

As a programmer, I wanted to find a place to record down some useful stuffs as my references, which are including frequently used codes for my current work and study. Finally, I found here, where I can put the source codes formally, It's really cool!

Moreover, I will use english to write my blog, for improving my poor English writing skills hopefully :)

Well, let's me put some source codes here:

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;
using  System.Globalization;

namespace  DCTProcess
{
    
public partial class Form1 : Form
    
{
        
public Form1()
        
{
            InitializeComponent();
        }


        
private void btnTransform_Click(object sender, EventArgs e)
        
{
            CultureInfo ci 
= new CultureInfo("en-us");
            
double[,] myOriValue = new double[88];
            
double[,] myTransValue = new double[88];
            
//int x, y = 0;
            char[] delimiterChars = ',' };

            
string myOritext = richtxt1.Text;
            
string[] myOriValueS = myOritext.Split(delimiterChars);

            richTextBox2.Text 
= "";

            
//make the 1d array to be 2d array
            for (int i = 0; i < 64; i++)
            
{
                
int myX, myY = 0;
                myY 
= (int) Math.Truncate((double)i/8); 
                myX 
= i % 8;
                myOriValue[myX, myY] 
= double.Parse(myOriValueS[i]);            
            }


            
//4 levels loop for the formula
            for (int xa = 0; xa <= 7; xa++)
            
{
                
for (int ya = 0; ya <= 7; ya++)
                
{
                    myTransValue[xa, ya] 
= GetK(xa) * GetK(ya) * InnerLoop(xa,ya,myOriValue);
                }

            }


            
//Display the result F matrix
            for (int yc = 0; yc <= 7; yc++)
            
{
                
for (int xc = 0; xc <= 7; xc++)
                
{
                    
int spacer = 12;
                    spacer 
-= myTransValue[xc, yc].ToString("F02", ci).Length;
                    richTextBox2.Text 
+= myTransValue[xc, yc].ToString("F02",ci);
                    
for (int sp = 0; sp < spacer; sp++)
                        richTextBox2.Text 
+= " ";
                }

                richTextBox2.Text 
+= " ";
            }

        }


        
private double GetK(int value)
        
{
            
if (value == 0)
                
return 1 / (2 * Math.Sqrt(2));
            
else
                
return 0.5;
        }


        
private double InnerLoop(int myM, int myN, double[,] myArray)
        

            
double result = 0;
            
double pi = Math.PI;
            
for (int xb = 0; xb <= 7; xb++)
            
{
                
for (int yb = 0; yb <= 7; yb++)
                
{
                    result 
+= myArray[xb, yb] * Math.Cos(((2 * xb + 1* myM * pi) / 16* Math.Cos(((2 * yb + 1* myN * pi) / 16);
                }

            }

            
return result;
        }

    }

}

Above coding (written in C#) is a part of my school assignment, which is DCT process for getting the F matrix during JPEG encoding. :)

引用\[1\]:当遇到"Failed to execute script 'entry_point' due to unhandled exception"错误时,可能有几个原因导致。首先,检查是否有缺少必要的模块或库,可能需要安装或更新相关的依赖项。其次,确保代码中没有导入错误,比如引用了不存在的模块或函数。还要检查是否有文件路径错误或文件损坏的问题。最后,还要确保系统环境变量设置正确,特别是PYTHONPATH变量。\[1\]\[2\] 引用\[3\]:另外,如果遇到"Failed to execute script 'entry_point' due to unhandled exception"错误,也可能是因为系统环境配置问题。例如,在Ubuntu 20.04 server上安装了Python3.9,但在修改默认Python版本时,不小心删除了/usr/bin/python3软连接,导致某些文件无法找到对应的Python版本。解决方法是将系统原文件/usr/lib/python3/dist-packages/lsb_release.py复制到/usr/bin目录下,可以使用命令sudo cp /usr/lib/python3/dist-packages/lsb_release.py /usr/bin来完成。\[3\] 综上所述,当遇到"Failed to execute script 'entry_point' due to unhandled exception"错误时,可以通过检查缺少的模块、导入错误、文件路径错误、文件损坏以及系统环境配置等方面来解决问题。 #### 引用[.reference_title] - *1* *2* [Failed to execute script ‘first‘ due to unhandled exception:cannot import name问题](https://blog.csdn.net/wm9028/article/details/124527206)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Failed to execute script entry_point与Command ‘lsb_release -a‘ returned non-zero错误-安装miniconda...](https://blog.csdn.net/qq_55059421/article/details/126333811)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值