In my code written for fractal image compression I got an error as :
Out of memory. Type HELP MEMORY for your options.
Error in tformarray (line 228)
B(prod(fsize_B)) = A(1);
Error in imtransform (line 275)
B = tformarray(args.A, args.tform, args.resampler, tdims_a, tdims_b, ...
Error in test1_UI (line 85)
I = imtransform(I,tform);
How can i resolve this?
my code where this happens is as follows :
[optimizer, metric] = imregconfig('monomodal');
% find the affine transformation from the damain block to range block
for rR=1:nrR
for cR=1:ncR
i=1;
for rd=1:nrD
for cd=1:ncD
s(i)= ssim(caR{rR,cR},imresize(caD{rd,cd},[64 64]));
if s(i)== d(rR,cR)
tformO = imregtform(caD{rd,cd},caR{rR,cR},'affine',optimizer,metric);
T(rR,cR) = tformO;
else
i=i+1;
end
end
end
d(rR,cR) = max(s);
end
end
clear d
% A - any initial image
A = imread('lena_jpgx80.jpg');
I = A;
for rR=1:nrR
for cR=1:ncR
tform = maketform('affine',T(rR,cR).T);
I = imtransform(I,tform);
i=i+1;
end
end
imshow(I)
Related
I have no clue what is wrong with this code, it is literally saying that a for loop that is perfectly fine, is attempting to get a vector3 value.
local locations = {}
local Players = game:GetService("Players")
local function SplitString(String)
local CurrentString = ""
local x = 1
for i = 1, #String do
local FullString = string.sub(String,1,i)
local Character = string.sub(String,i,i)
local CurrentString = string.sub(String, x, i)
print(locations[1])
if Character == "," then
CurrentString = string.sub(String,x,i-1)
table.insert(locations,CurrentString)
x = i + 1
CurrentString = string.sub(String, x , i)
print(locations)
end
--Add the character to the string.
if Character == " " then
x = i + 1
CurrentString = string.sub(String, x, i + 1)
end
if #FullString + 1 == #String then
table.insert(locations, CurrentString)
end
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoidrootpart = char:WaitForChild("HumanoidRootPart")
wait(5)
while humanoidrootpart do
local location = humanoidrootpart.position
print(location)
SplitString(location)
print(locations[1])
local RoundLocatX = math.floor(locations[1]*50)/50
local RoundLocatZ = math.floor(locations[3]*50)/50
local RoundLocatXLength = RoundLocatX.length
local RoundLocatZLength = RoundLocatZ.length
if RoundLocatX > 50 then
print('hi')
end
wait(1)
end
end)
end)
This is the error:
ServerScriptService.Terrain Generation:9: attempt to get length of a Vector3 value
I would post this on the roblox forum but they are stupid and require some dumb amount of reading time to be able to post on it.
Your error is pointing at this line :
for i = 1, #String do
and saying that you are trying to get the length of a Vector3 object. That means that #String is not working as expected. So looking at the object you passed into the SplitString function...
local location = humanoidrootpart.position
print(location)
SplitString(location)
Your location variable is a Vector3, not a string, and it doesn't support the length operator, #.
But you don't have to parse it as a string to get the values out of it. Since it is a Vector3, you can simply index the different values in it.
local location = humanoidrootpart.Position
local RoundLocatX = math.floor(location.X * 50) / 50
local RoundLocatZ = math.floor(location.Z * 50) / 50
I leveled up my character and got some items, when i rejoined, it didn't load my previous data, It gave me level 0 and didn't load any items (it didn't give any output for level problem, but it gave this output for item problem: 'for' limit must be a number), but PLD.ItemNumber is a number, because It is from "ItemNumber" variable in the saving function. How to fix it? Code:
local DataStoreService = game:GetService("DataStoreService");
local PD = DataStoreService:GetDataStore("PlayerData");
function SaveData(Player)
local TableSave = {};
TableSave.Level = Player.PlayerData.Stats.Level.Value;
local TableItems = {};
local ItemNumber = 0;
for i,v in pairs(Player.PlayerData.Items:GetChildren()) do
ItemNumber = ItemNumber + 1;
TableItems["Item"..ItemNumber]={};
local TI = TableItems["Item"..ItemNumber];
TI.ItemName = v.Name;
TI.Level = v.Level.Value;
TI.Damage = v.Damage.Value;
end
table.insert(TableSave,TableItems);
TableSave.ItemNumber = ItemNumber;
PD:SetAsync(Player.userId,TableSave);
end
function LoadData(Player)
local success, err = pcall(function()
PLD = PD:GetAsync(Player.userId);
end)
if success then
Player.PlayerData.Stats.Level.Value = PLD.Level;
for i = 1,PLD.ItemNumber do
local CurrentItem = Instance.new("Folder");
CurrentItem.Name = PLD[1]["Item"..i].ItemName;
local Lv = Instance.new("IntValue");
Lv.Name = "Level";
Lv.Value = PLD[1]["Item"..i].Level;
Lv.Parent = CurrentItem;
local Dm = Instance.new("IntValue");
Dm.Name = "Damage";
Dm.Value = PLD[1]["Item"..i].Damage;
Dm.Parent = CurrentItem;
CurrentItem.Parent=Player.PlayerData.Items;
end
else
print("ERROR IN GET ASYNC");
end
end
game.Players.PlayerRemoving:Connect(function(plr)
repeat wait() until plr.PlayerData;
SaveData(plr);
end)
game.Players.PlayerAdded:Connect(function(plr)
repeat wait() until plr.PlayerData;
LoadData(plr);
end)
Objective: to change color intensity of pixels
Code:
using Images, ImageView;
function updateColors(path::String)
if isfile(path)
img = load(path);
chnlView = channelview(img);
chnlView[chnlView .> 0.7] = 0.9;
imshow(img);
else
info("Error: Image Not Found!");
end
end
#By Prof.Bogumił Kamiński
function quit()
print("Press q to quit!");
while true
opt = getChar();
if opt == 'q'
break
else
continue
end
end
end
#By Prof.Bogumił Kamiński
function getChar()
ret = ccall(:jl_tty_set_mode, Int32, (Ptr{Cvoid},Int32), stdin.handle, true)
ret == 0 || error("unable to switch to raw mode")
c = read(stdin, Char)
ccall(:jl_tty_set_mode, Int32, (Ptr{Cvoid},Int32), stdin.handle, false)
c
end
updateColors("/opt/julia/pictures/test.jpg");
quit();
Error:
no method matching setindexshape(::Float64, ::Int64)
Please help me in resolving the issue!
You should broadcast the assignment operation like this:
chnlView[chnlView .> 0.7] .= 0.9
I'm trying to make flv file from images via the following Matlab code.The problem is converting bmp images fo flv.
I'm almost new in this section of Matlab. do you have any Idea?
clear
clc
vidobj = videoinput('winvideo',2);
preview(vidobj);
No_snapshot = 5;
interval = 1;
Format = 'bmp';
PathName = uigetdir;
tic;
count = 0;
date_temp = datevec(now);
date_string_vid = [num2str(date_temp(1)),'-',num2str(date_temp(2)),'-',num2str(date_temp(3)),'-',...
num2str(date_temp(4)),'-',num2str(date_temp(5)),'-',num2str(date_temp(6))];
while 1
if fix(toc/interval) > count
count = fix(toc/interval);
date_string = num2str(count);
imwrite(getsnapshot(vidobj),[PathName,'\',date_string,'.' Format], Format);
end
if count >= No_snapshot
break;
end
end
closepreview;
delete(vidobj);
% =========================================================================
PathName = 'G:\capture_video\movie1\';
obj=VideoWriter(date_string_vid,'Grayscale AVI');
open(obj)
for m=1:No_snapshot
m1=imread([PathName,num2str(m),'.bmp']);
% m1=double(m1(:,:,1));
F = im2frame(m1);
aviObject = addframe(obj,F); % Add the frame to the AVI file
end
close(obj)
There are many reports of slow performance of Octave's dlmread. I was hoping that this was fixed in 3.2.4, but when I tried to load a csv file that has a size of ca. 8 * 4 mil (32 mil in total), it also took very, very long time. I searched the web but could not find a workaround for this. Does anybody know a good workaround?
I experienced the same problem and had R handy, so my solution was to use "read.csv" in R, and then use the R package "R.matlab" to write a ".mat" file, and then load that in Octave.
"read.csv" can be pretty slow too, but this worked very well in my case.
The reason is that Octave has a bug that adding data to a very large matrix takes more time then adding the same amount of data to a small matrix.
Below is my try. I choose to save data each 50000 lines, so meanwhile I could already take a look instead of being forced to wait. It is slower for small files, but much faster for larger files.
function alldata = load_data(filename)
fid = fopen(filename,'r');
s=0;
data=[];
alldata=[];
save "temp.mat" alldata;
if fid == -1
disp("Couldn't find file mydata");
else
while (~feof(fid))
line = fgetl(fid);
[t1,t2,t3,t4,d] = sscanf(line,'%i:%i:%i:%i %f', "C"); #reading time as hh:mm:ss:ms and data as float
s++;
t = (t1 * 3600000 + t2 * 60000 + t3 * 1000 + t4);
data = [data; t, d];
if (mod(s,10000) == 0)
#disp(s), disp(" "), disp(t), disp(" "), disp(d), disp("\n");
disp(s);
fflush(stdout);
end
if (mod(s,50000) == 0)
load "temp.mat";
alldata=[alldata; data];
data=[];
save "temp.mat" alldata;
disp("data saved");
fflush(stdout);
end
end
disp(s);
load "temp.mat";
alldata=[alldata; data];
save "temp.mat" alldata;
disp("data saved");
fflush(stdout);
end
fclose(fid);
Here is a workaround that I am using.
I did not find that sscanf will parse input lines as indicated above. Also, I didn't use the temp file.
My .csv file has a large number of rows. They begin with a header of 18 lines and are followed by a data block, each of which has 135 columns. The following code has been tested. My file also begins each row with a dd/mm/yyyy hh:mm field. This will also catch poor lines and indicate where they are by using try/catch.
My .csv file came from a customer who dumped his PARCView load in an Excel file.
function [tags,descr,alldata] = fbcsvread(filename)
fid = fopen(filename,'r');
s = 0;
data=[];
alldata=zeros(1,135);
if fid==-1
disp("Couldn't find file %s\n",filename);
else
linecount = 1;
while (~feof(fid))
line = fgetl(fid);
data2 = zeros(1,135);
if linecount == 1
tags = strsplit(line,",");
elseif linecount == 2
descr = strsplit(line,",");
elseif linecount >= 19
data = strsplit(line,",");
datetime = strsplit(char(data(1))," ");
modyyr = strsplit(char(datetime(1)),"/");
hrmin = strsplit(char(datetime(2)),":");
year1 = sscanf(char(modyyr(3)),"%d","C");
day1 = sscanf(char(modyyr(2)),"%d","C");
month1 = sscanf(char(modyyr(1)),"%d","C");
hour1 = sscanf(char(hrmin(1)),"%d","C");
minute1 = sscanf(char(hrmin(2)),"%d","C");
realtime = datenum(year1,month1,day1,hour1,minute1);
data2(1) = realtime;
for location = 2:134
try
data2(location) = sscanf(char(data(location)),"%f","C");
catch
printf("Error at %s %s\n",char(datetime(1)),char(datetime(2)) );
fflush(stdout);
end_try_catch
endfor
alldata(linecount-18,:) = data2;
if mod(linecount,50) == 0
printf(".");
fflush(stdout);
endif
endif
linecount = linecount + 1;
endwhile
fclose(fid);
endif
endfunction