이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to decrypt a .mat file ?
조회 수: 22 (최근 30일)
이전 댓글 표시
Hi,
Is there any way to go about this? I need an information on how to decrypt a given .mat file named "conf.mat" ?
I have to use this configuration file and make changes on its loaded parameters to suite my work.
Is there anyway this can be decrypted ?
Thanks
댓글 수: 8
Rik
2018년 10월 23일
If you are not using Matlab, then you could take a look at how Octave handles loading mat files. That is open source, so you should be able to find the implementation.
Chidiebere Ike
2018년 10월 23일
I am using Matlab but can't seem to modify the .mat file content. I can as well use other tools if available. Thank you
Rik
2018년 10월 23일
You can use the load function to load your variable to a struct, and then use save to write it back to the file. You have to jump through some hoops to automatically put all variables back into the mat file under the name you loaded it.
Chidiebere Ike
2018년 10월 23일
편집: Chidiebere Ike
2018년 10월 23일
Thanks for the information. I appreciate. I tried this approach but noticed it didn't show all content but few. Also tried achieving this via octave still the same. The parameters I am looking forward to modifying isn't displayed compared to when I view the file from Matlab as it is. Any reason for this ?
Fangjun Jiang
2018년 10월 23일
Please clarify the content of the .mat file, workspace data, or Simulink configuration/customization? MAT file can be used in many different ways these days. You might not use it in the right way.
MOUSSAOUI FAOUZI
2021년 12월 31일
Hello, all my Matlab files have been encrypted by ransomware online. Is there a way to recover and decrypt Matlab files? Thank you. moussaoui39fa@gmail.com
채택된 답변
John D'Errico
2018년 10월 23일
편집: John D'Errico
2018년 10월 23일
I believe the complete file specs for a .mat file are not published outside of The MathWorks. That means if you want to fully "decrypt" a .mat file, then change a variable, and save it back out, you have one good option - get a job at The MathWorks.
Of course even then, you still have a problem. Since the .mat files have changed format at times over the years with release changes, anything you did would be potentially version specific, and might not work with a different release.
So the only reliable solution to your problem is to not solve it as you wish. Instead, use load. Load the file, then modify the variables in question, and finally save it back out. This solution is easy and incredibly fast to implement, instead of the complex approach you seem to want to follow.
As far as your comment that you tried it, but not all content was shown, just means you may not understand how to properly use load, or perhaps are not using MATLAB properly. So it is difficult to help you there without seeing what confused you and what you indeed did try.
댓글 수: 44
Chidiebere Ike
2018년 10월 23일
편집: Walter Roberson
2018년 10월 23일
Lol. Thanks John. I did get your points clearly and I have been able to achieve the changes via your suggestion. However, I have issues with a code published on Matlab via this link https://www.mathworks.com/matlabcentral/fileexchange/38200-fast-non-local-mean-image-denoising-implementation. Corrections where made on the codes via the comments but I still have errors when I made the suggested corrections and applied the code in my proposed algorithm. The error reads below:
Index exceeds matrix dimensions.
Error in FAST_NLM_II (line 54)
SqDist =
Sd(PatchSizeHalf+WindowSizeHalf+1:Height+WindowSizeHalf+PatchSizeHalf,PatchSizeHalf+WindowSizeHalf+1:Width+WindowSizeHalf+PatchSizeHalf)...
% lower right corner
I will appreciate contributions.
Thank you
John D'Errico
2018년 10월 23일
Use the debugger. It is always the way to solve such a problem. You can set it to interrupt processing at the point where an error occurs.
Check the size of the matrix involved. Then check the index. That index is not consistent with size of the matrix being indexed. How it got that way, I can only guess is due to a change that you made. So you would need to look at variables like PatchSizeHalf, etc. The debugger allows you to look at the values of each variable.
Chidiebere Ike
2018년 10월 23일
편집: Walter Roberson
2018년 10월 23일
Thanks for your response. As suggested by a staff here that I break it down into smaller parts and I did.
whos Sd
[rows, columns] = size(Sd)
index1 = PatchSizeHalf+WindowSizeHalf+1
index2 = Height+WindowSizeHalf+PatchSizeHalf
index3 = PatchSizeHalf+WindowSizeHalf+1
index4 = Width+WindowSizeHalf+PatchSizeHalf
On running the above, it's observed that index2 is not bigger than rows, or index4 is not bigger than columns. I did tried to replace breakdown above in Line 56 on the original whose link I shared earlier. Below information was obtained to show the differences in index size
whos Sd
[rows, columns] = size(Sd)
index1 = PatchSizeHalf+WindowSizeHalf+1
index2 = Height+WindowSizeHalf+PatchSizeHalf
index3 = PatchSizeHalf+WindowSizeHalf+1
index4 = Width+WindowSizeHalf+PatchSizeHalf)
Name Size Bytes Class Attributes
Sd 522x522 2179872 double
rows =
522
columns =
522
index1 =
7
index2 =
518
index3 =
7
index4 =
518
Here is an error obtained after I had replaced the breakdown above in Line 56 of the original code.
Undefined function or variable 'SqDist'.
Error in FAST_NLM_II (line 64)
w = exp(-SqDist/(2*Sigma^2));
Quite frustrating at this point.
Thanks
Walter Roberson
2018년 10월 23일
You appear to have missed
SqDist = Sd(index1:index2, index3:index4);
Perhaps the code is in a loop and the problem does not occur the first time, but does occur in some other iteration. You can add in
if rows < index2 || columns < index4
error('indices (%d:%d,%d:%d) out of range for Sd, which is (%d,%d)', index1, index2, index3, index4, rows, columns);
end
Chidiebere Ike
2018년 10월 23일
편집: Walter Roberson
2018년 10월 23일
Thanks Walter. I did made corrections as advised. I replaced the said lines of code with the below:
[rows, columns] = size(Sd);
SqDist = Sd(index1:index2, index3:index4);
index1 = PatchSizeHalf+WindowSizeHalf+1;
index2 = Height+WindowSizeHalf+PatchSizeHalf;
index3 = PatchSizeHalf+WindowSizeHalf+1;
index4 = Width+WindowSizeHalf+PatchSizeHalf;
if rows < index2 || columns < index4
error('indices (%d:%d,%d:%d) out of range for Sd, which is (%d,%d)', index1, index2, index3, index4, rows, columns);
end
I obtained the error below, please guide me if I missed it.
Undefined function or variable 'index1'.
Error in FAST_NLM_IIcorrected (line 56)
SqDist = Sd(index1:index2, index3:index4);
Error in FNLM_NLM_II (line 175)
AO = FNLM_NLM_II(AO,9,15,0.15); % Filtered AO sub-bands
Fangjun Jiang
2018년 10월 23일
the line SqDist = Sd(index1:index2, index3:index4); needs to be put after the lines where index1, ..., index4 are created.
Chidiebere Ike
2018년 10월 23일
편집: Walter Roberson
2018년 10월 23일
Thanks Jiang for your response.
Here is the lines of code inputed:
%%NLM_II
% Get Image Info
[Height,Width] = size(NoisyImg);
% Initialize the denoised image
u = zeros(Height,Width);
% Initialize the weight max
M = u;
% Initialize the accumlated weights
Z = M;
% Pad noisy image to avoid Borader Issues
PaddedImg = padarray(NoisyImg,[PatchSizeHalf,PatchSizeHalf],'symmetric','both');
PaddedV = padarray(NoisyImg,[WindowSizeHalf,WindowSizeHalf],'symmetric','both');
% Main loop
for dx = -WindowSizeHalf:WindowSizeHalf
for dy = -WindowSizeHalf:WindowSizeHalf
if dx ~= 0 || dy ~= 0
% Compute the Integral Image
% Sd = integralImgSqDiff(PaddedImg,dx,dy);
Sd = integralImgSqDiff(PaddedV,dx,dy);
% Obtaine the Square difference for every pair of pixels
whos Sd
[rows, columns] = size(Sd);
index1 = PatchSizeHalf+WindowSizeHalf+1;
index2 = Height+WindowSizeHalf+PatchSizeHalf;
index3 = PatchSizeHalf+WindowSizeHalf+1;
index4 = Width+WindowSizeHalf+PatchSizeHalf;
SqDist = Sd(index1:index2, index3:index4);
if rows < index2 || columns < index4
error('indices (%d:%d,%d:%d) out of range for Sd, which is (%d,%d)', index1, index2, index3, index4, rows, columns);
end
end
Here is the error message:
Name Size Bytes Class Attributes
Sd 514x514 2113568 double
Index exceeds matrix dimensions.
Error in FAST_NLM_IIcorrected (line 61)
SqDist = Sd(index1:index2, index3:index4);
Error in FAST_NLM_II (line 175)
Walter Roberson
2018년 10월 23일
Put the line
SqDist = Sd(index1:index2, index3:index4);
after the "if rows" test.
Chidiebere Ike
2018년 10월 23일
편집: Walter Roberson
2018년 10월 23일
I did.
% Compute the Integral Image
% Sd = integralImgSqDiff(PaddedImg,dx,dy);
Sd = integralImgSqDiff(PaddedV,dx,dy);
% Obtaine the Square difference for every pair of pixels
whos Sd
[rows, columns] = size(Sd);
index1 = PatchSizeHalf+WindowSizeHalf+1;
index2 = Height+WindowSizeHalf+PatchSizeHalf;
index3 = PatchSizeHalf+WindowSizeHalf+1;
index4 = Width+WindowSizeHalf+PatchSizeHalf;
if rows < index2 || columns < index4
error('indices (%d:%d,%d:%d) out of range for Sd, which is (%d,%d)', index1, index2, index3, index4, rows, columns);
end
SqDist = Sd(index1:index2, index3:index4);
Error received:
In FNLM_LANR (line 190)
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate.
RCOND = NaN.
> In FNLM_LANR (line 190)
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate.
RCOND = NaN.
> In FNLM_LANR (line 190)
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate.
RCOND = NaN.
> In FNLM_LANR (line 190)
1/5 "Set5/baby_GT.bmp" [512 x 512]
Scale-Up GR.
Elapsed time is 1.430249 seconds.
Scale-Up ANR.
Elapsed time is 2.136054 seconds.
Scale-Up LANR.
Elapsed time is 1.420766 seconds.
Preprocessing, Iter 0 : PSNR = NaN; SSIM = NaN
Preprocessing, Iter 10 : PSNR = NaN; SSIM = NaN
Preprocessing, Iter 20 : PSNR = NaN; SSIM = NaN
Preprocessing, Iter 30 : PSNR = NaN; SSIM = NaN
No values of PSNR and SSIM was obtained.
Walter Roberson
2018년 10월 23일
We do not seem to have the source for FNLM_LANR so we do not know what is near line 190.
Walter Roberson
2018년 10월 23일
Line 190 of your code is a mkdir() call. But line 182 is
conf.PPsTMM{i} = 1*Hi*inv(Lo'*Lo + 1e-5*diag(1./(vals(1:clustersz)).^11) )*Lo';
You should essentially never use inv(), it is not robust enough.
conf.PPsTMM{i} = 1*Hi*((Lo'*Lo + 1e-5*diag(1./(vals(1:clustersz)).^11)) \ Lo');
There is still a possibility that this will complain about singularity. I suggest you calculate
temp = (Lo'*Lo + 1e-5*diag(1./(vals(1:clustersz)).^11);
if size(temp,1) ~= size(temp,2)
error('Non-square temp, cannot have inverse');
end
if ~all(isfinite(temp(:)))
error('temp contains nan or inf, inverse would be nan');
end
rtemp = rank(temp);
if rtemp ~= size(temp,1)
error('temp is rank deficient, only rank %d instead of %d, no inverse', rtemp, size(temp,1));
end
conf.PPsTMM{i} = 1*Hi*(temp \ Lo');
Chidiebere Ike
2018년 10월 23일
편집: Chidiebere Ike
2018년 10월 23일
Ops. Sorry for the initial message.
if true
% %%Each column in PPs corresponds to a atom in D_l
for i = 1:length(conf.points)
[vals idx] = sort(D(i,:), 'descend');
if (clustersz >= size(conf.dict_lores,2)/2)
conf.PPs{i} = conf.PP;
else
Lo = conf.dict_lores(:, idx(1:clustersz));
Hi = conf.dict_hires(:, idx(1:clustersz));
% conf.PPsTMM{i} = 1*Hi*inv(Lo'*Lo + 1e-5*diag(1./(vals(1:clustersz)).^11) \ Lo');
% conf.dict_middle(:,i) = conf.PPsTMM{i}*conf.dict_lores(:,i);
temp = (Lo'*Lo + 1e-5*diag(1./(vals(1:clustersz))).^11);
if size(temp,1) ~= size(temp,2)
error('Non-square temp, cannot have inverse');
end
if ~all(isfinite(temp(:)))
error('temp contains nan or inf, inverse would be nan');
end
rtemp = rank(temp);
if rtemp ~= size(temp,1)
error('temp is rank deficient, only rank %d instead of %d, no inverse', rtemp, size(temp,1));
end
conf.PPsTMM{i} = 1*Hi*(temp \ Lo');
conf.dict_middle(:,i) = conf.PPsTMM{i}*conf.dict_lores(:,i);
end
end
end
Error message obtained :
if true
% code Error using FNLM_LANR (line 189)
temp contains nan or inf, inverse would be nan
>>
end
Chidiebere Ike
2018년 10월 24일
Most likely. The values are much in a 1024 x 1024 matrix. Please find attached. Thank you
Walter Roberson
2018년 10월 24일
You could try zipping it. However as compression is already typically used, that might not help enough to fit within 5 megabytes. You could post a link to Google Drive or Dropbox.
Walter Roberson
2018년 10월 24일
DD appears to be safely finite and invertible.
I guess I will need Lo and vals as of the time that the problem arises.
Chidiebere Ike
2018년 10월 24일
Walter Roberson
2018년 10월 24일
Your vals vector is entirely nan, so when you mix in 1/vals on the diagonal, everything comes out nan.
Chidiebere Ike
2018년 10월 24일
편집: Chidiebere Ike
2018년 10월 24일
Ok. Pls How do I resolve this.. ? Thank you
Chidiebere Ike
2018년 10월 24일
편집: Walter Roberson
2018년 10월 25일
I did run my codes successfully using the original code via this link:
But I observed that the original code compares only the lower right part of each patch, alongside the central pixel.
I do wish to compare the entire patch for a robust denoising; hence modification or corrections is required on the FAST_NLM_II file.
On executing the Corrections made via the comments gives several errors till date.
Thats my situation.
Thank you
Walter Roberson
2018년 10월 25일
vals is derived from D. The only way for vals to have come out nan would be if D came out as nan. But when I asked you to attach D, you attached a matrix that was not nan in any location. However, the matrix you attached was named DD, which appears to be a different matrix.
So, something odd is happening.
Please execute the command
dbstop if naninf
and then run your code. You might see some routine tests in the code that should be ignored; if so, then command
dbcont
to continue going. Keep doing that until you find a nan or inf value being generated that you do not expect.
Chidiebere Ike
2018년 10월 25일
Ok. Thanks. I will do as advised. However, D and DD is the same as I used it as different notations for different code samples...
Chidiebere Ike
2018년 10월 25일
편집: Walter Roberson
2018년 10월 25일
Hello Mr. Walter. Upon executing the above mentioned codes, attached is what I obtained. However, I have attached some files.
1. FAST_NLM_II (Original code) ran successfully with my proposed algorithm with the attached D.mat and vals.mat file (No Nan values).
2. FAST_NLM with the corrections made so far on this thread, failed with NAN values.
I do intend to make the corrections on FAST_NLM as I observed that the FAST_NLM_II(original code) compares only the lower right part of each patch, alongside the central pixel.
I do wish to compare the entire patch for a robust denoising; hence modification or corrections is required on the FAST_NLM file.
I shared the above links so you could see the D and vals files for FAST_NLM_II which ran successfully. It's quite challenging to achieve this task but hopefully will.
I really appreciate your support..
Thanks
Walter Roberson
2018년 10월 25일
I have loaded in the code. What arguments should I be passing to the routines?
Chidiebere Ike
2018년 10월 25일
The input to the function is a Noisy or low-resolution image to efficiently denoise it. Thank you
Walter Roberson
2018년 10월 26일
In order to reproduce your problem it would help if I had the same image you are working on, and you indicated the other three parameters such as the HalfWindow size.
Chidiebere Ike
2018년 10월 26일
편집: Walter Roberson
2018년 10월 26일
OK Walter. Please find attached images that I use.
AO here is the Approximation sub-band to be filtered with the parameters below:
A1 = FAST_NLM_II(AO,9,15,0.15);
PatchSizeHalf = 9
WindowSizeHalf = 15
Sigma = 0.15
Detailed sub-bands (H1,H2,H3) are filtered with the same parameters below:
D1 = FAST_NLM_II(H1,3,3,0.15);
D2 = FAST_NLM_II(H2,3,3,0.15);
D3 = FAST_NLM_II(H3,3,3,0.15);
PatchSizeHalf = 3
WindowSizeHalf = 3
Sigma = 0.15
Thanks
Walter Roberson
2018년 10월 26일
편집: Walter Roberson
2018년 10월 26일
I try things like
AO = rgb2gray(im2double(imread('baby_GT.bmp'))); A1 = FAST_NLM_II(AO,9,15,0.15);
but no error shows up.
I do not know what H1, H2, H3 are to be.
Walter Roberson
2018년 10월 26일
You should post some code that takes is from input image name like 'baby_GT.bmp' to the point of reproducing the problem. It might only be a few lines, but we do not know what those lines are.
Chidiebere Ike
2018년 10월 26일
편집: Walter Roberson
2018년 10월 26일
Here is the code I am working with that gives me the error when I tried to make the corrections Geert mentioned via the link below. Also Set5 in the input which contains the 5 pics I sent earlier:
If you find time, you can see the comments on that link. I do wish to compare the entire patch for a robust denoising rather than comparing only the lower right part of each patch, alongside the central pixel in FAST_NLM_II(original code) as published by Yue Wu
I need modifications of the function file to achieve the above.
This is my greatest desire on FAST_NLM_II function file. Please note, the errors I mentioned earlier shows up when I try to make corrections of Geert on the function files as stated in his comment via the link above. The original function file gives no error with my code.
Thank you
Walter Roberson
2018년 10월 26일
I loaded in everything, made sure all the directories were on my path, made sure I was invoking your new Demo_LANR instead of the one from the google drive (the google drive one does not invoke FAST_LANR* at all), made sure I copied over the files from Set5 of the google drive.
And... I am not having any difficulty. No error messages.
The only warning messages have to do with the addpath() that are not needed anyhow because I had already added the appropriate directories to the path.
Chidiebere Ike
2018년 10월 26일
Can you please share your own code from your end? Both the main code and function file FAST_NLM_II you used.. So I can compare with mine. And try to figure what went wrong and where. I appreciate your effort and guide. Thanks so much
Walter Roberson
2018년 10월 26일
I did not make any changes to your code. I installed all of the code, used pathtool to ensure that the various directories were on the path, copied Set5 into place; and executed. Along the way I did need to cd into a couple of directories and "make" to compile some of the tools because I am on Mac and the precompiled versions happened to be for Windows (this showed up as clear missing function messages, not as nan showing up.)
Chidiebere Ike
2018년 10월 27일
편집: Walter Roberson
2018년 10월 27일
Hello Mr. Walter. I tried to create a function file for Demo_LANR_NLM for the code via https://github.com/junjun-jiang/LANR-NLM/blob/master/Demo_LANR_NLM.m but got stocked at a point. How do I achieve this successfully. I will appreciate if you could help or guide me create the Demo_LANR_NLM file in a function file. I have attached what I did so far.
Thanks
Walter Roberson
2018년 10월 27일
You have
for i = 1:numel(midres)
features = collect(conf, {midres{i}}, conf.upsample_factor, conf.filters);
features = double(features);
end
You do not output features anywhere, so there would not appear to be any point in calculating them.
You are overwriting all of the variable features each round of the loop.
Chidiebere Ike
2018년 10월 27일
편집: Chidiebere Ike
2018년 10월 27일
The attachment I made was what I did so far.
Please please guide me through this sir to achieve this. I wish to compare this Demo_LANR_NLM method alongside other methods with my proposed method and will be good to have DEMO_LANR_NLM in function file like I had others such as BICUBIC, Global Regressor, ANR, LANR etc on "methods" folder.
What I always do is to run the Demo_LANR_NLM code separately to obtain its PSNR and SSIM values and images quality… And run my proposed code separately as well to compare both.
So I felt it will be better to run all at once in my code. Just like the Demo_LANR_NLM code had bicubic, ScSR, ANR, GR and LANR etc in its list of the methods to be compared.
Thats all.
Guide me sir
추가 답변 (1개)
Walter Roberson
2018년 10월 23일
https://www.mathworks.com/matlabcentral/answers/15521-matlab-function-save-and-v7-3
Mat files are not encrypted. They are data files, many of the entries are compressed. See the link for Malcolm's utilities.
댓글 수: 2
Fangjun Jiang
2018년 10월 23일
The OP's question and comments are misleading. They sounded complicated but it turned out to be not knowing a simple command. Now the Q&A are completely off topic.
Chidiebere Ike
2018년 10월 23일
편집: Chidiebere Ike
2018년 10월 23일
I am sorry about that Jiang. My first issue has been solved. Then I presented another here. Here is the link https://www.mathworks.com/matlabcentral/answers/425033-how-do-i-solve-this-error-index-exceeds-matrix-dimensions#comment_625175..
Any contribution will be appreciated.
Thank you so much
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)